0

Decrypting and encrypting string in python using module in lib . easiest way to do it

import hashlib
a="abcd"
a = hashlib.sha224(a)
z=a.hexdigest()

print  p

now I want to decrypt that string which I entered before..

0

2 Answers 2

4

You don't encrypt the string, you hash it. Therefore, it can't be "decrypted" - hashes are meant to be one way functions, i.e. there is no simple way to "calculate" the input from the output.

See e.g. here for more detailed definitions of encrypting and hashing: Difference between Hashing a Password and Encrypting it

Sign up to request clarification or add additional context in comments.

2 Comments

Oh !! thanks...is there any way of encrypting and decrypting a string
hm searching for that ("python encryption" or similar) on the search engine of your choice should give plenty results... what about this: stackoverflow.com/a/16761459/671366 or this: eli.thegreenplace.net/2010/06/25/… ?
3

You are creating a hash of the input string. You can use this hash to check if another input string is the same as the original input string.

You are not supposed to be able to decrypt a hash. That would defeat the whole purpose.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.