Is there any method to generate MD5 hash of a string in Java?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
You need
java.security.MessageDigest.Call
MessageDigest.getInstance('MD5')to get a MD5 instance ofMessageDigestyou can use.The compute the hash by doing one of:
byte[]and calculate the hash in one operation withmd.digest(bytes).MessageDigestonebyte[]chunk at a time by callingmd.update(bytes). When you’re done adding input bytes, calculate the hash withmd.digest().The
byte[]returned bymd.digest()is the MD5 hash.