Created
January 29, 2019 17:10
-
-
Save erfelipe/fe642014d7096bd6e85093fa28ee33fa to your computer and use it in GitHub Desktop.
Java SHA-256 #hash
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
//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