Hash with python and escape from a certain minister's egosa

Introduction

The other day, I read the article here, and I also want to hash it and surpass the Minister's Egoza! I thought about it and studied about hashing of python. So, this time I would like to share what I learned.

Hashing overview

-The algorithm converts the character string into a character string with invisible regularity. (Example) Before hashing: sample          ↓ After hashing: b80f059f7c6301c6fb2a34615edca2634bc65fa6

-There are many types of hashing algorithms. -The character string generated by hashing is called a hash value. -It is difficult to estimate the original character string from the hash value. In other words, it is easy to convert from "original data to hash value", but it is difficult to estimate "hash value to original data". -Since it is generated by the specified algorithm, the same hash value is generated no matter how many times the same data is hashed. -If the original data changes a little, the generated hash value will be completely different. There are features such as.

Confirmation of hashlib compatible algorithm

hash_list.py


import hashlib

print(sorted(hashlib.algorithms_guaranteed))
#['blake2b', 'blake2s', 'md5', 'sha1', 'sha224', 'sha256', 'sha384', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'sha512', 'shake_128', 'shake_256']
print(sorted(hashlib.algorithms_available))
#['DSA', 'DSA-SHA', 'MD4', 'MD5', 'MDC2', 'RIPEMD160', 'SHA', 'SHA1', 'SHA224', 'SHA256', 'SHA384', 'SHA512', 'blake2b', 'blake2s', 'dsaEncryption', 'dsaWithSHA', 'ecdsa-with-SHA1', 'md4', 'md5', 'mdc2', 'ripemd160', 'sha', 'sha1', 'sha224', 'sha256', 'sha384', 'sha3_224', 'sha3_256', 'sha3_384', 'sha3_512', 'sha512', 'shake_128', 'shake_256', 'whirlpool']

algorithms_guaranteed: Shows "standard support" hash algorithms. algorithms_available—Displays “available” hash algorithms.

Sample code

This time, I will introduce three.

hash_sample.py


import hashlib
hash_before_word = 'I do not want to work'

# MD5
hash_after_word_md5 = hashlib.md5(hash_before_word.encode()).hexdigest()
print(hash_after_word_md5)
#450ba26c03d7740818d9b0f2bb97bc5

# blake2b
hash_after_word_blake2b = hashlib.blake2b(hash_before_word.encode()).hexdigest()
print(hash_after_word_blake2b)
#52e284d94dfdc8e88c2926f234907127e98738e03e96f21a510e4822e0891385154430de8c047a4c4868199aad8b8db093d3a995952d17c738e77cab7875acf9

# sha224
hash_after_word_sha224 = hashlib.sha224(hash_before_word.encode()).hexdigest()
print(hash_after_word_sha224)


In this way, it can be hashed by multiple hash algorithms. If you want to use another hash algorithm, just change the hash algorithm name.

Summary

This time, I introduced the hashing algorithm using python. 67344549d15075a087a77f88e1ad920b21a387a9 Please use the minister's egosurfing and password management. (However, keep ethics)

No, it's ffd4a94997286e73f1031aa7464b0d0cd1213bfd.

reference

https://docs.python.org/ja/3/library/hashlib.html

Recommended Posts

Hash with python and escape from a certain minister's egosa
Get data from MySQL on a VPS with Python 3 and SQLAlchemy
A memo with Python2.7 and Python3 on CentOS
2. Make a decision tree from 0 with Python and understand it (2. Python program basics)
python + faker Randomly generate a point with a radius of 100m from a certain point
Make a decision tree from 0 with Python and understand it (4. Data structure)
Create a decision tree from 0 with Python and understand it (5. Information Entropy)
Building a python environment with virtualenv and direnv
Launch a web server with Python and Flask
Create a decision tree from 0 with Python (1. Overview)
Read line by line from a file with Python
Extract data from a web page with Python
WEB scraping with python and try to make a word cloud from reviews
Build a python virtual environment with virtualenv and virtualenvwrapper
Let's make a simple game with Python 3 and iPhone
I made a LINE BOT with Python and Heroku
Build a python virtual environment with virtualenv and virtualenvwrapper
Get mail from Gmail and label it with Python3
[Python] Start a batch file from Python and pass variables.
Perform a Twitter search from Python and try to generate sentences with Markov chains.
Programming with Python and Tkinter
A memo that reads data from dashDB with Python & Spark
Encryption and decryption with Python
Create a decision tree from 0 with Python and understand it (3. Data analysis library Pandas edition)
Python and hardware-Using RS232C with Python-
Associate Python Enum with a function and make it Callable
A learning roadmap that allows you to develop and publish services from scratch with Python
Let's create a PRML diagram with Python, Numpy and matplotlib.
Installation procedure for Python and Ansible with a specific version
Detect objects of a specific color and size with Python
Solving with Ruby, Perl, Java and Python AtCoder ATC 002 A
I made a server with Python socket and ssl and tried to access it from a browser
Try to bring up a subwindow with PyQt5 and Python
Make a fortune with Python
Python: Create a dictionary from a list of keys and values
python with pyenv and venv
Collecting information from Twitter with Python (MySQL and Python work together)
Library for specifying a name server and dig with python
Create a directory with python
With skype, notify with skype from python!
Shoot time-lapse from a PC camera using Python and OpenCV
Works with Python and R
[5th] I tried to make a certain authenticator-like tool with python
I made a simple circuit with Python (AND, OR, NOR, etc.)
[2nd] I tried to make a certain authenticator-like tool with python
Build a 64-bit Python 2.7 environment with TDM-GCC and MinGW-w64 on Windows 7
Build a Python environment on your Mac with Anaconda and PyCharm
Create a striped illusion with gamma correction for Python3 and openCV3
Build a detonation velocity website with Cloud Run and Python (Flask)
[3rd] I tried to make a certain authenticator-like tool with python
How to make a surveillance camera (Security Camera) with Opencv and Python
Try to extract a character string from an image with Python3
Make a simple OMR (mark sheet reader) with Python and OpenCV
I made a Nyanko tweet form with Python, Flask and Heroku
Draw a watercolor illusion with edge detection in Python3 and openCV3
I tried to make a periodical process with Selenium and Python
Read a file in Python with a relative path from the program
Make a scraping app with Python + Django + AWS and change jobs
Solve the Python knapsack problem with a branch and bound method
[4th] I tried to make a certain authenticator-like tool with python
[1st] I tried to make a certain authenticator-like tool with python