Skip to content

Instantly share code, notes, and snippets.

@gnumilanix
Created August 27, 2020 01:31
Show Gist options
  • Save gnumilanix/8ec743ec488506ba1e6fff6fd99ac381 to your computer and use it in GitHub Desktop.
Save gnumilanix/8ec743ec488506ba1e6fff6fd99ac381 to your computer and use it in GitHub Desktop.
Hash function for 2c2p
fun generateHash(data: String, key: String, algorithm: String): String {
val secretKeySpec = SecretKeySpec(key.toByteArray(), algorithm.type)
val mac = Mac.getInstance(algorithm)
mac.init(secretKeySpec)
return Hex.encodeHexString(mac.doFinal(data.toByteArray()))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment