39

I wanted to create a python program thats asks for an input then hashes(sha-256) the input then prints it. Does this already exist? How would I go about doing so.

zamir
  • 2,144
  • 1
  • 11
  • 23
User9123
  • 596
  • 2
  • 7
  • 14

1 Answers1

75

using hashlib:

from hashlib import sha256

input_ = input('Enter something: ')
print(sha256(input_.encode('utf-8')).hexdigest())
zamir
  • 2,144
  • 1
  • 11
  • 23
  • Note: This throws a NameError in Python 2.7. So, if you get that error, you need to change your interpreter to Python 3. – John Jun 27 '21 at 10:26