Skip to main content
May 7, 2010
Question

Matching md5sum

  • May 7, 2010
  • 1 reply
  • 1371 views

I have a bunch of files with md5 numbers generated from the md5sum unix command.  I thought that I could use the #hash(xFile,"MD5")# function in Coldfusion to match the hashes.  But, it seems the hashes are different.  Is there some different command I can use that will make it so these numbers will match?

--ja

    This topic has been closed for replies.

    1 reply

    Inspiring
    May 8, 2010

    It should work. What type of file and what are you passing in for #xFile#?

    May 8, 2010

    Here is my code.  I added some extra hoping that maybe it was an encoding type that I had wrong.  But no luck.

    <cfset joomlaPROD = "motherJoomla">

    <cfquery name="data2"

    datasource="#joomlaPROD#">

        select jos_docman.id, `dmname`,

    dmdescription, dmfilename

        from jos_docman 

        where dmfilename like 'w-sw7-13.pdf'

        limit 1     

    </cfquery>

    Output of md5sum from linux: 053f35a9c39ec156c9f1fd8a56fc0d8a  /web/joomla/dmdocuments/w-sw7-13.pdf<br />

    <br />

    <cfoutput

    query="data2">

    #dmfilename# --

    <cffile action="read" file="/web/joomla/dmdocuments/#dmfilename#" variable="xFile"/>

    #hash(xFile,"MD5")# <br />

    #hash(xFile,"CFMX_COMPAT")# <br/>

    #hash(xFile,"SHA")# <br />

    #hash(xFile,"SHA-256")# <br/>

    #hash(xFile,"SHA-384")# <br />

    #hash(xFile,"SHA-512")# <br/>

    #hash(xFile,"MD5","US-ASCII")# <br />

    #hash(xFile,"MD5","ISO-8859-1")#<br />

    #hash(xFile,"MD5","ISO-8859-2")# <br/>

    #hash(xFile,"MD5","ISO-8859-4")# <br />

    #hash(xFile,"MD5","ISO-8859-5")#<br />

    #hash(xFile,"MD5","ISO-8859-7")# <br/>

    #hash(xFile,"MD5","ISO-8859-9")# <br />

    #hash(xFile,"MD5","ISO-8859-13")#<br />

    #hash(xFile,"MD5","ISO-8859-15")# <br />

    #hash(xFile,"MD5","UTF-8")#<br />

    #hash(xFile,"MD5","UTF-16")# <br />

    #hash(xFile,"MD5","UTF-16BE")#<br />

    #hash(xFile,"MD5","UTF-16LE")# <br />

    And, here is the output where you can see that even though I have all these encoding types, I don't get a match:
    w-sw7-13.pdf -- C85E8606EFF5B1D4919647DC9FD6872C
    AA285B3F5B8D7483BB7B5158C9641D9D
    2DA518C50835EFB6CA0196CA56BAB17E35338287
    8510B7643506426187277ACAE1D687533DC9101594EF168747F4B9A8C7BB4BF6
    17EF8A1C0DDFE3704AF24D6C8CF83B2A4919CD4D4013FAB0272B8A7EC2A086E19B3B30440604
    CE557BC06E08D2C0B3D4
    A66BDAE9D51D967F92EE81B768EC12C957D72E1DA387B606C4FC5388D343BAC62FC59333D8E7
    1A132B0E0855923E420273A6557E7265E0860998DF5EEC6BA7A1
    7962B30C69BE38315B42EB73976A26A2
    AD4C75D9809D5BF272DC66CCA2024826
    6A71C6170565C0D9EAA82F2EB1DB5F13
    D1FAB7F3F72EAE65EEA470EBCF429EC2
    DD9337BC93D3879106BB495CBA49B2C8
    EB60AA3561668493D69C4A7BC32A7792
    FD4A0166E53F41B6F6A876BEF77795C9
    8771D4E17B9A401A6A2D3E7555A5B6A9
    E4DEF4FF50E3AE62A33B3DA165C2F653
    C85E8606EFF5B1D4919647DC9FD6872C
    0E68B6E858E7FF636AE621782A158CF7
    1EA1F2A8E4041A597BAA78D858A656B3
    1FFE840CA070794A89F31E1690E8779E

    Inspiring
    May 8, 2010

    Scratch that. I forgot CF's hash(..) does not accept binary.

    Message was edited by: -==cfSearching==-