0 Replies Latest reply on Jun 22, 2007 8:41 AM by Nafiganado

    Decrypting DESEDE-encrypted string from C#

    Nafiganado Level 1
      quote:


      <cfset bytearray = ArrayNew(1)>
      <cfset bytearray[1] = 154>
      ...
      <cfset bytearray[24] = 242>

      <cfset key = ToBase64(BinaryDecode(bytearraytohexstring(bytearray), "HEX"))>

      <cfset bytearray = ArrayNew(1)>
      <cfset bytearray[1] = 141>
      ...
      <cfset bytearray[8] = 30>

      <cfset vector = BinaryDecode(bytearraytohexstring(bytearray), "HEX")>

      <cfset bytearray = ArrayNew(1)>
      <cfset bytearray[1] = 11>
      ...
      <cfset bytearray[16] = 210>

      <cfset encodedValue = bytearraytohexstring(bytearray)>

      <cfset decodedValue = DecryptBinary(BinaryDecode(encodedValue , "HEX"), key, "DESEDE/CFB/NoPadding", vector)>



      Decoded value is NOT correct. Why? We have compared the result of encoding the same string in C# and CF and it's different, ALTHOUGH we use the same algorithm, key and vector (of course), 'no padding' here and there and 'CFB' (feedback mode, 8bit block size).

      BTW, when encoding string as utf-16 in CF,
      resulted HEX length is (number of characters) x 2 + 2 (why?!)
      and in C# it's always (number of characters) x 2.

      What's going on? :(

      p.s. bytearraytohexstring is checked: output is correct. It produces hex string like 'A0BCFFDE....blablabla'