Skip to content

Instantly share code, notes, and snippets.

@laughingman7743
Last active August 29, 2015 14:03
Show Gist options
  • Select an option

  • Save laughingman7743/afa557696632d1ae248e to your computer and use it in GitHub Desktop.

Select an option

Save laughingman7743/afa557696632d1ae248e to your computer and use it in GitHub Desktop.
public static String generateSHA1(String str) {
String digestStr = null;
try {
MessageDigest digest = MessageDigest.getInstance("SHA");
digest.update(str.getBytes());
digestStr = new String(Hex.encodeHex(digest.digest()));
} catch (NoSuchAlgorithmException e) {
Logger.error("Unknown algorithm.", e);
}
return digestStr;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment