# Triple DES as cryptographic hash function

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-*?

• The HAC can provide standard constructions. – SEJPM Oct 21 '15 at 12:31
• We can't guess what TripleDES(data, key) does when data is larger than 8 bytes, which is apparently the case. Using any standard operating mode, either MyHash 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. – fgrieu Oct 21 '15 at 12:39
• maybe using 3DES as in CBC-MAC with a fixed key? just guessing, still not analyzed the scheme. – ddddavidee Oct 21 '15 at 12:50
• I can't use a fixed key. I really need to make irreversible. – Igor Gatis Oct 21 '15 at 12:52