FileHash

FileHash["file"]
gives an integer hash code for the contents of the specified file.

FileHash["file","type"]
gives an integer hash of the specified type.

DetailsDetails

  • Values generated by FileHash are based on the raw bytes in a file.
  • Possible hash code types include:
  • "Adler32"Adler 32-bit cyclic redundancy check
    "CRC32"32-bit cyclic redundancy check
    "MD2"128-bit MD2 code
    "MD5"128-bit MD5 code
    "SHA"160-bit SHA-1 code
    "SHA256"256-bit SHA code
    "SHA384"384-bit SHA code
    "SHA512"512-bit SHA code
  • FileHash by default uses 128-bit MD5 code.
  • FileHash["file","type",n] gives the hash code for the first n bytes of the file.
  • FileHash["file","type",-n] gives the hash code for the last n bytes.
  • FileHash["file","type",{m,n}] gives the hash code for bytes m through n.
  • FileHash["file","type",0] gives the hash code for 0 bytes.
  • FileHash works not only on files, but also on streams.
  • FileHash[obj,] effectively extracts data at the specified range of byte positions in the stream obj, ignoring any previous stream position.

ExamplesExamplesopen allclose all

Basic Examples  (3)Basic Examples  (3)

The fingerprint of a file:

In[1]:=
Click for copyable input
Out[1]=

The hash code of a file:

In[1]:=
Click for copyable input
Out[1]=

The hash code in hexadecimal form:

In[1]:=
Click for copyable input
Out[1]=
Introduced in 2007
(6.0)
| Updated in 2010
(8.0)