How to do hash calculation with salt in Python

Since there is a hashlib module, it can be easily implemented. I wrote in the title that it has salt, but it's also easy because you can add "Salt + Data" to hashlib.

・ Implementation method

!/usr/bin/env python

import hashlib

message = "salt" + "data"

print "MD5: " + hashlib.md5(message).hexdigest()
print "sha256: " + hashlib.sha256(message).hexdigest()
print "sha516: " + hashlib.sha512(message).hexdigest()
~~~~~~~

 Here, md5, sha256, and sha516 are used.

#### ·Verification

./hash.py MD5: 23eeeb4347bdd26bfc6b7e ・ ・ ・ sha256: 11a4a60b518bf24989d481468076e5d59828846265b857 ・ ・ ・ sha516: ecc579811643b170cbd88fd0d0e323d1e1acc7cef8f73483a7 ・ ・ ・


 Since the output is long and difficult to see due to line breaks, I omitted it with "...".
 It's actually longer (especially sha512)


Recommended Posts

How to do hash calculation with salt in Python
How to do R chartr () in Python
How to work with BigQuery in Python
How to do portmanteau test with python
[REAPER] How to play with Reascript in Python
How to use tkinter with python in pyenv
How to develop in Python
How to convert / restore a string with [] in python
Explain in detail how to make sounds with python
How to do zero-padding in one line with OpenCV
How to run tests in bulk with Python unittest
Python: How to use async with
How to collect images in Python
How to use SQLite in Python
To do tail recursion with Python2
How to get started with Python
What to do with PYTHON release?
How to use Mysql in python
How to wrap C in Python
How to use ChemSpider in Python
How to use FTP with Python
How to use PubChem in Python
How to calculate date with python
How to handle Japanese in Python
How to extract any appointment in Google Calendar with Python
How to do Bulk Update with PyMySQL and notes [Python]
How to log in to AtCoder with Python and submit automatically
How to do arithmetic with Django template
How to deal with python installation error in pyenv (BUILD FAILED)
[Introduction to Python] How to use class in Python?
How to not escape Japanese when dealing with json in python
Try logging in to qiita with Python
How to dynamically define variables in Python
[Itertools.permutations] How to put permutations in Python
How to create a heatmap with an arbitrary domain in Python
How to use python put in pyenv on macOS with PyCall
How to get a stacktrace in python
How to display multiplication table in python
How to extract polygon area in Python
How to check opencv version in python
How to display python Japanese with lolipop
How to switch python versions in cloud9
How to adjust image contrast in Python
How to use __slots__ in Python class
How to dynamically zero pad in Python
How to enter Japanese with Python curses
How to do Server-Sent Events in Django
To work with timestamp stations in Python
How to use regular expressions in Python
[Python] How to deal with module errors
How to display Hello world in python
How to use is and == in Python
How to display legend marks in one with Python 2D plot
How to write Ruby to_s in Python
How to install python3 with docker centos
How to calculate "xx time" in one shot with Python timedelta
How to get the date and time difference in seconds with python
It's more recent, but I wanted to do BMI calculation with python.
How to deal with old Python versions in Cloud9 made by others
How to upload with Heroku, Flask, Python, Git (4)
How to deal with memory leaks in matplotlib.pyplot