-3

I simply want to hash a string (a Password) in Python 3. How do I do that? What is a Simple Way of doing that? Could you please give a Coding example or Recommend me a Module that can use.

copycode
  • 11
  • 3

2 Answers2

0

You can hash values in Python 3 with Hashlib:

import hashlib
h = hashlib.new('sha256')#sha256 can be replaced with diffrent algorithms
h.update('Hello World'.encode()) #give a encoded string. Makes the String to the Hash 
print(h.hexdigest())#Prints the Hash
urwolfiii
  • 53
  • 6
0

I don't think there can be an easier way than using the built-in keyword hash:

In [1]: hash("Hello, world!")
Out[1]: 7195831199436619873
user1717828
  • 6,812
  • 6
  • 31
  • 52