How one can get the SHA512 sum of a string the usage of Python


If you need to get the SHA512 sum of a string using Python, then you can do the following.

Step 1

Firstly, we need to use the hashlib module:

import hashlib

Step 2

Now make sure that the input string is encoded correctly.

your_input = "this is your input string".encode('utf-8')

Step 3

Finally use the sha512 function of the hashlib module, and get the hexdigest() value from it:

hashlib.sha512(your_input).hexdigest()

Putting it all together

import hashlib

your_input = "this is your input string".encode('utf-8')
hashed = hashlib.sha512(your_input).hexdigest()

print(hashed)

# --> 74cf60b5a22c401454e36193a65e7efeb5a7d72db9e1f786975e7bd2b7bdd12dee83f99e78542d0eca5c9152f09f397d0ac8de68275ca353837b28f938e429f4

Leave a Reply

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