The MD2 is a Message-Digest Algorithm. It is a cryptographic hash function developed by Ronald Rivest in 1989. It is optimized for 8-bit computers. The MD2 algorithm is used in public key infrastructures as part of certificates generated with MD2 and RSA. From 2014, this algorithm is now not considered as a secure algorithm.
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 as follows:
These algorithms are initialized in static method called getInstance(). After selecting the algorithm the message digest value is calculated and the results are returned as a byte array. BigInteger class is used, to convert the resultant byte array into its signum representation. This representation is then converted into a hexadecimal format to get the expected MessageDigest.
Input : hello world
Output : d9cce882ee690a5c1ce70beff3a78c77
Input : GeeksForGeeks
Output : 787df774a3d25dca997b1f1c8bfee4af
Below program shows the implementation of MD2 hash in Java.
HashCode Generated by MD2 for: GeeksForGeeks : 787df774a3d25dca997b1f1c8bfee4af hello world : d9cce882ee690a5c1ce70beff3a78c77
- Data Integrity
- SHA-512 Hash In Java
- SHA-224 Hash In Java
- SHA-384 Hash In Java
- SHA-256 Hash in Java
- MD5 hash in Java
- Implementing our Own Hash Table with Separate Chaining in Java
- SHA-1 Hash
- Hash Functions in System Security
- Data Structures | Hash | Question 5
- Data Structures | Hash | Question 2
- Data Structures | Hash | Question 3
- Data Structures | Hash | Question 4
- Data Structures | Hash | Question 1
- String hashing using Polynomial rolling hash function
- What is HMAC(Hash based Message Authentication Code)?
- Java.util.LinkedList.poll(), pollFirst(), pollLast() with examples in Java
- Java.util.function.DoublePredicate interface in Java with Examples
- Java.util.BitSet class methods in Java with Examples | Set 2
- Java.util.function.LongPredicate interface in Java with Examples
- Java.util.Collections.disjoint() Method in java with Examples