Convert string into SHA-256 hash key for encryption in python

Developerking
Jan 16, 2023

To generate a SHA-256 hash key, you can use a variety of programming languages and libraries. Here is an example of how to generate a SHA-256 hash in Python:

import hashlib

# String to be hashed
data = "example"

# Create SHA-256 hash object
hash_object = hashlib.sha256()

# Update the hash object with bytes of the string
hash_object.update(data.encode())

# Get the hexadecimal representation of the hash
hash_hex = hash_object.hexdigest()

print(hash_hex)

This will output a 64-character hexadecimal string, which is the SHA-256 hash of the input data.

Sign up to discover human stories that deepen your understanding of the world.

Free

Distraction-free reading. No ads.

Organize your knowledge with lists and highlights.

Tell your story. Find your audience.

Membership

Read member-only stories

Support writers you read most

Earn money for your writing

Listen to audio narrations

Read offline with the Medium app

Developerking
Developerking

Written by Developerking

We are creating the world's largest community of developers & Share knowledgeable contents , So Stay Tuned & Connect with us !! Become a Dev King Member.

No responses yet

Write a response