VOOZH about

URL: https://www.geeksforgeeks.org/java/md5-hash-in-java/

⇱ MD5 hash in Java - GeeksforGeeks


  • Courses
  • Tutorials
  • Interview Prep

MD5 hash in Java

Last Updated : 30 Aug, 2022

To calculate cryptographic hashing value in Java, MessageDigest Class is used, under the package java.security. 

MessageDigest Class provides following cryptographic hash function to find hash value of a text, they are: 

  1. MD5 
  2. SHA-1 
  3. SHA-256 

This Algorithms are initialize in static method called getInstance(). After selecting the algorithm it calculate the digest value and return the results in byte array. 

BigInteger class is used, which converts the resultant byte array into its sign-magnitude representation

This representation converts into hex format to get the MessageDigest 

Examples:

Input : hello world
Output : 5eb63bbbe01eeed093cb22bb8f5acdc3

Input : GeeksForGeeks
Output : e39b9c178b2c9be4e99b141d956c6ff6

Implementation:


Output
Your HashCode Generated by MD5 is: e39b9c178b2c9be4e99b141d956c6ff6
Comment
Article Tags:
Article Tags: