Generate a hash value using the HMAC method.

How to generate a hash value using the HMAC method.

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)

The result is as follows

python


8b1be576578bd4725ff7733f44fb8d7afed21808
40

Recommended Posts

Generate a hash value using the HMAC method.
Reuse the behavior of the @property method by using a descriptor [16/100]
How to generate a query using the IN operator in Django
Generate a Docker image using Fabric
Check the return value using PEP 380
The story that a hash error came out when using Pipenv
Finding the optimum value of a function using a genetic algorithm (Part 1)
Saddle point search using the gradient method
Try cluster analysis using the K-means method
Add a layer using the Keras backend
Write a TCP server using the SocketServer module
Isn't there a default value in the dictionary?
Create a GUI on the terminal using curses
Approximate a Bezier curve through a specified point using the least squares method in Python
Python: Calculate the uniform flow depth of a rectangular cross section using the Brent method
Calculation of the shortest path using the Monte Carlo method
Get the file name in a folder using glob
Cut a part of the string using a Python slice
Determine the threshold using the P tile method in python
Creating a graph using the plotly button and slider
DJango Note: From the beginning (using a generic view)
I tried clustering ECG data using the K-Shape method
Generate that shape of the bottom of a PET bottle
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 2 ~
[Python] Mask the image into a circle using Pillow
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 3 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 4 ~
[CRUD] [Django] Create a CRUD site using the Python framework Django ~ 5 ~
A little bit from Python using the Jenkins API
Create a dictionary by searching the table using sqlalchemy
How to get only the data you need from a structured data set using a versatile method