0 Replies Latest reply on Sep 21, 2009 1:55 AM by david_spangler

    How to encrypt data SHA-1 / TDES / Base64

    david_spangler

      I need to encrypt a piece of data to submit to a remote server. The server requires the following format:

       

      MAC = Base64(TDES(KEY,SHA-1(DATAITEM)))

       

      I successfully completed the SHA-1 hash, but cannot get the TDES encryption to match the remote server. The information I have is that it needs to be ripleDES, Fixed Key, DESede/CBC/NoPadding, iv = "00000000"

       

      The correct data should be like

      Data:test
      Key:123456781234567812345678
      SHA-1:A94A8FE5CCB19BA61C4C0873D391E987982FBBD300000000          
      TDES:FDDADB7E2DD648E3AF3816FB5EF0696C7C887F1ED1BCADBA          
      Base64:/drbfi3WSOOvOBb7XvBpbHyIfx7RvK26

       

      So far I'm stuck at

      <cfset string = "test">

      <cfset key = "123456781234567812345678">

       

      <cfset string_sha = #Hash(string, "SHA")# & "00000000">

      this delivers the proper results

       

      <cfset string_tdes = #Encrypt(string_sha, key, "DESEDE")#>

      this give me an error with the key, and incorrect data if i create a new key

       

      <cfset MAC = #ToBase64(string_tdes)#>

      this give a data string way too long to match the correct one.

       

      i'm totally stumped. any obvious mistakes?

       

      cheers & thanks for any help.