Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How can I generate an 16-character long MD5 hash in Java?

I need to generate on Kotlin a MD5 hash for some data, but as 16-characterString, not a 32-character String. I found no way fo that at this point and need help. But there is definitely a mothod exist, since I found website, which do it correctly.

Please check as example these sites:

https://www.freecodeformat.com/md516.php

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

https://www.freecodeformat.com/md5.php

As a control I am using this string – "1681799732000". The first site generates the correct answer with 16 characters – "92AA8DDBE039D480", The second link – 32 digit string – "E292561C92AA8DDBE039D4808CC51159".

Generating 32 character MD5 in Kotlin not a problem, but 16 character – actually is.

Could you kindly help me with this question?

EDIT 1 – Encoding is presumably UTF-8

>Solution :

If you put your control string into each of those you get back:

16:         92aa8ddbe039d480
32: e292561c92aa8ddbe039d4808cc51159

The 16 character result appears to be the 32 character result with the first and last 8 characters removed.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading