Skip to content

Instantly share code, notes, and snippets.

@giusepperizzo
Created May 3, 2015 17:08
Show Gist options
  • Save giusepperizzo/630d32cc473069497ac1 to your computer and use it in GitHub Desktop.
Save giusepperizzo/630d32cc473069497ac1 to your computer and use it in GitHub Desktop.
// import javax.xml.bind.DatatypeConverter;
// import java.io.UnsupportedEncodingException;
// import java.security.MessageDigest;
// import java.security.NoSuchAlgorithmException;
// import java.util.UUID;
public static void main(String[] args) {
String hash;
try {
String ID = "";
hash = DatatypeConverter.printHexBinary(
MessageDigest.getInstance("SHA-1").digest(ID.getBytes("UTF-8")));
UUID uuid = UUID.nameUUIDFromBytes(hash.getBytes());
System.out.println(uuid.toString());
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment