Created
December 21, 2015 07:04
-
-
Save DinoChiesa/505be4116258c007cbc8 to your computer and use it in GitHub Desktop.
Compute SHA-256 in Java
This file contains hidden or 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
import java.security.MessageDigest; | |
import org.apache.commons.codec.binary.Base64; | |
... | |
MessageDigest md = MessageDigest.getInstance("SHA256"); | |
byte[] hashBytes = md.digest(stringToHash.getBytes("UTF-8")); | |
String hashB64 = Base64.encodeBase64String(hashBytes); | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment