MD5 is very collision resistant. The algorithm was designed to generate unique hash values for each unique input. However, lately there have been rumblings in the security community about the weaknesses in MD5. Many government agencies will be required to move to a stronger algorithm in a few years.
Advantages of MD5
- Utilizes a fast computation algorithm
- Provides collision resistance
- Is in widespread use
- Provides a one-way hash
- Has known security flaws and vulnerabilities
- Is less secure than the SHA-1 algorithm
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 | import java.security.*; public class MD5 { public static void main(String[] args) { String passwordToHash = "HELLOWORLD"; StringBuilder sb = new StringBuilder(); try { MessageDigest md = MessageDigest.getInstance("MD5"); md.update(passwordToHash.getBytes()); byte[] bytes = md.digest(); for(int x=0; x< bytes.length ;x++){ sb.append(String.format("%02x", bytes[x])); } } catch (NoSuchAlgorithmException e) { e.printStackTrace(); } System.out.println(sb.toString()); } } |
No comments:
Post a Comment