Skip to content

Instantly share code, notes, and snippets.

@axtstar
Last active June 9, 2017 06:46
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 axtstar/57cd2417fedfec16dd527e6bcdf399ec to your computer and use it in GitHub Desktop.
Save axtstar/57cd2417fedfec16dd527e6bcdf399ec to your computer and use it in GitHub Desktop.
make SHA-256 digest and BASE64 encode on scala
def getSha256MD(input:String) = {
val md = java.security.MessageDigest.getInstance("SHA-256")
val ha = new sun.misc.BASE64Encoder().encode(md.digest(input.getBytes))
ha
}
val input = "input"
getSha256MD(input)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment