I need to generate a hash for a small piece of data (~50 bytes). I'd normally use MD5 or SHA but that's not available in the platform I'm programming for.
Luckily, it provides Triple DES and I thought I could use it as cryptographic hash function (pseudo-code):
function MyHash(text)
data = padded(text, 64)
key = data[0:8] + data[8:16] + data[16:24]
encrypted = TripleDES(data, key)
return encrypted[0:16]
MyHash
will produce 128-bit (16-bytes) long hashes for input text.
Is MyHash
secure? How does it compare with MD5 and SHA-*?
TripleDES(data, key)
does when data is larger than 8 bytes, which is apparently the case. Using any standard operating mode, eitherMyHash
is not a function (it won't give the same result when called twice with the same input), or bytes starting from the 25th in the input (and the low-order bits of the 17th to 24th bytes) do not influence output. In either case,MyHash
is a poor cryptographic hash function. $\endgroup$ – fgrieu Oct 21 '15 at 12:39