Thursday, July 23, 2009

Example: Generating a SHA hash in Java

import java.security.MessageDigest;
...
public String createHashSHA (String someString){

try {
MessageDigest md = MessageDigest.getInstance("SHA");
md.update(someString.getBytes());
byte[] someStringDigest = md.digest();
String someStringHashSHA = new String(someStringDigest);
return someStringHashSHA;
}
catch (Exception e){
...
}
}

No comments:

Post a Comment