MD5 Encryption Using Java

Demonstrates how to encrypt a string using the MD5 algorithm in Java. Since MD5 is non-reversable, there is no code for decrypting the value.

Contextual Ads

More Java Resources


  1. import java.math.*;
  2. import*;
  3. String toEnc = “Encrypt This!”// Value to encrypt
  4. MessageDigest mdEnc = MessageDigest.getInstance(“MD5”)// Encryption algorithm
  5. mdEnc.update(toEnc.getBytes()0, toEnc.length());
  6. String md5 = new BigInteger(1, mdEnc.digest()).toString(16) // Encrypted string

Leave a Reply

Your email address will not be published. Required fields are marked *

Back To Top