Python3 Create sha256 from Input Text

Python3 script to receive input text and change it to sha256 hashing text. Usually we can use it to create password and store it in database.

import hashlib
strPassword = input("Enter the password: ")
hash_object = hashlib.sha256(strPassword.encode())
print(hash_object.hexdigest())

A note for hexdigest() command, it means that the hash_object is printed in hex/ printable letter format. Otherwise it will result like this “<sha256 HASH object @ 0x7f8db1acddb0>

There are many hashing type we can use beside sha256 like md5, sha512, sha224.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.