Python Tutorial

Saturday, July 13, 2013

hmac - Keyed hashing

Python hmac is a Keyed-Hashing for Message Authentication. Here we also can set digest mode, default mode is md5.

import hmac
import hashlib

print hmac.new("python","msg1", hashlib.sha256).hexdigest()
print hmac.new("python","msg2", hashlib.sha256).hexdigest()
print hmac.new("python","msg3", hashlib.sha256).hexdigest()

Output:
eb96a956ee4df54f5e2cd94bf326925c9405f989a69c64948f3b05f75c38f880
bcd3d2a7bb7d3ff12085a494c19de671a96a1892e75bb6a0e8bbee87473d873f
68a3d9807b17d303324dc24853f5c949076161a271ff41209da863e9e91f96e6

0 comments:

Post a Comment