Geekpedia Programming Tutorials









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.

On Saturday, April 19th 2008 at 01:08 AM
By Andrei Pociu (View Profile)
-----   (Rated 0 with 0 votes)
Contextual Ads
More Java Resources
Advertisement
  1. import java.math.*;
  2. import java.security.*;
  3.  
  4. String toEnc = "Encrypt This!"; // Value to encrypt
  5. MessageDigest mdEnc = MessageDigest.getInstance("MD5"); // Encryption algorithm
  6. mdEnc.update(toEnc.getBytes(), 0, toEnc.length());
  7. String md5 = new BigInteger(1, mdEnc.digest()).toString(16) // Encrypted string
Digg Digg It!     Del.icio.us Del.icio.us     Reddit Reddit     StumbleUpon StumbleIt     Newsvine Newsvine     Furl Furl     BlinkList BlinkList

Rate Rate this code snippet
Comment Current Comments
There are no comments.

Comment Comment on this tutorial
Name: Email:
Message:
Comment Related Source Code
There is no related code.

Comment Related Tutorials
There are no related tutorials.

Jobs Java Job Search
My skills include:
Enter a City:

Select a State:


Advanced Search >>
Latest Tech Bargains

Advertisement

Free Magazine Subscriptions

Today's Pictures

Today's Video

Other Resources

Latest Downloads

Latest Icons