Well, I kinda have a task where I have to take a file and generate MD5 hash of that file. Problem is that I can't really use any classes that would automate this processes so everything has to be programmed manually. And that prob would mean that I can't use java.security.MessageDigest >> getInstance("MD5") to get an MD5 message. So yeah I am not really sure how to write needed algorithm because it seems that everyone uses MessageDiggest Class. Any ideas?
Asked
Active
Viewed 887 times
-1
-
2I don't really understand why you can't use `MessageDigest`. But if you want you can read the specification (https://www.ietf.org/rfc/rfc1321.txt) and write a program to implement it. Make sure you test it extensively. – Henry Feb 27 '19 at 12:44
-
1I agree with Henry. When testing, be sure to validate your implementation by comparing the MD5 hashes generated with it with MD5 hashes generated by another implementation that is known to be correct. – Stephen C Feb 27 '19 at 12:48
2 Answers
0
Well I see 2 options:
Either you write your own java version, starting from the algorithm written in pseudo-code.
Or you try to reverse-engineer an existing one. If you use java 8, you have to look at the class
sun.security.provider.MD5

Benoit
- 5,118
- 2
- 24
- 43
0
I found this implementation of MD5: https://rosettacode.org/wiki/MD5/Implementation#Java
I haven't tested if this is 100% correct though