I need to produce a Hash value based off of a variable length string that I can store within a field no longer than 16 (due to vendor requirements).
I am concatenating together several strings that are being passed through a C# script transformation in order to calculate the Hash. I am constrained by the vendor's file specification in that the output of the hash cannot be any longer than 16.
Does anyone have any suggestions? As an example the string conversion of the MD5 algorith has a length of 32.
The cryptographic has functions are designed such that you may truncate the output to some size and the truncated hash function remains a secure cryptographic hash function. For example, if you take the first 128 bits (16 bytes) of the output of SHA-512 applied to some input, then the first 128 bits are a cryptographic hash as strong as any other 128-bits cryptographic hash.
The solution is to choose some cryptographic hash function - SHA-256, SHA-384, and SHA-512 are good choices - and truncate the output to 128 bits (16 bytes).
--EDIT--
Based on the comment that the hash value must, when encoded to ASCII, fit within 16 ASCI characters, the solution is
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With