Created
February 14, 2010 10:08
-
-
Save nazt/303938 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.security.MessageDigest | |
// Create a Message Digest from a Factory method | |
MessageDigest md = MessageDigest.getInstance("SHA1"); | |
// Create the message | |
String orig = "And now for something completely different... the larch."; | |
byte[] msg = orig.getBytes(); | |
// Update the message digest with some more bytes | |
// This can be performed multiple times before creating the hash | |
md.update(msg); | |
// Create the digest from the message | |
byte[] aMessageDigest = md.digest(); | |
// Printout | |
System.out.println("Original: " + new String(msg)); | |
System.out.println("Message Digest: " + new String(aMessageDigest)); | |
BigInteger bigInt = new BigInteger(1, aMessageDigest) | |
//aMessageDigest = md5sum | |
//http://www.jguru.com/faq/view.jsp?EID=4316 | |
//http://www.spiration.co.uk/post/1199/Java%20md5%20example%20with%20MessageDigest |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment