Created
October 30, 2017 14:33
-
-
Save regisfoucault/a6251db0286df6cd0c258d9d912620c5 to your computer and use it in GitHub Desktop.
Intercom Identity verification HMAC SH256
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 javax.crypto.Mac | |
import javax.crypto.spec.SecretKeySpec | |
def encryptSHA256(message: String, secret: String): String = { | |
val sha256_HMAC = Mac.getInstance("HmacSHA256") | |
val secret_key = new SecretKeySpec(secret.getBytes(), "HmacSHA256") | |
sha256_HMAC.init(secret_key) | |
sha256_HMAC.doFinal(message.getBytes()) | |
.map("%02X" format _) | |
.mkString | |
.toLowerCase | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment