LoginSignup
4
4

More than 5 years have passed since last update.

HMAC 方式を使用してハッシュ値を生成する。

Posted at

HMAC 方式を使用してハッシュ値を生成する方法。

hmac_digest.py
import sha
import hmac
from hashlib import sha1
key = 'foo'
raw = 'baa'
hashed = hmac.new(key, raw, sha1)
digested = hashed.hexdigest()
print digested
print len(digested)

結果は以下の通り

8b1be576578bd4725ff7733f44fb8d7afed21808
40
4
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
4