To calculate cryptographic hashing value in Java, MessageDigest Class is used, under the package java.security.
MessagDigest Class provides following cryptographic hash function to find hash value of a text, they are:
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
Input : hello world Output : 5eb63bbbe01eeed093cb22bb8f5acdc3 Input : GeeksForGeeks Output : e39b9c178b2c9be4e99b141d956c6ff6
Your HashCode Generated by MD5 is: e39b9c178b2c9be4e99b141d956c6ff6
Java Docs for MessageDigest
- What are Hash Functions and How to choose a good Hash Function?
- SHA-384 Hash In Java
- SHA-512 Hash In Java
- SHA-224 Hash In Java
- MD2 Hash In Java
- Implementing our Own Hash Table with Separate Chaining in Java
- SHA-1 Hash
- Hash Table vs STL Map
- Graph representations using set and hash
- Advantages of BST over Hash Table
- Hash Function for String data in C#
- Hash Functions in System Security
- Sorting using trivial hash function
- Sort elements by frequency | Set 4 (Efficient approach using hash)
- Overview of Data Structures | Set 2 (Binary Tree, BST, Heap and Hash)
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.