Skip to content

Instantly share code, notes, and snippets.

@erfelipe
Created January 29, 2019 17:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erfelipe/fe642014d7096bd6e85093fa28ee33fa to your computer and use it in GitHub Desktop.
Save erfelipe/fe642014d7096bd6e85093fa28ee33fa to your computer and use it in GitHub Desktop.
Java SHA-256 #hash
//Exemplo1:
MessageDigest digest = MessageDigest.getInstance("SHA-256");
byte[] hash = digest.digest(text.getBytes(StandardCharsets.UTF_8));
//Exemplo2:
I think that the easiest solution is to use Apache Common Codec:
String sha256hex = org.apache.commons.codec.digest.DigestUtils.sha256Hex(stringText);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment