Created
December 23, 2016 07:18
-
-
Save Vic020/001a89d4fe40e26f82a584cbef9ab7fc to your computer and use it in GitHub Desktop.
scala encryption util wrapper . Include md5 sha1 sha224 sha256 sha512
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
import java.security.MessageDigest | |
object EncryptionUtil { | |
def md5(string: String): String = MessageDigest.getInstance("MD5").digest(string.getBytes("UTF-8")).map("%02x".format(_)).mkString | |
def sha1(string: String): String = MessageDigest.getInstance("SHA-1").digest(string.getBytes("UTF-8")).map("%02x".format(_)).mkString | |
def sha224(string: String): String = MessageDigest.getInstance("SHA-224").digest(string.getBytes("UTF-8")).map("%02x".format(_)).mkString | |
def sha256(string: String): String = MessageDigest.getInstance("SHA-256").digest(string.getBytes("UTF-8")).map("%02x".format(_)).mkString | |
def sha512(string: String): String = MessageDigest.getInstance("SHA-512").digest(string.getBytes("UTF-8")).map("%02x".format(_)).mkString | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment