how to store values in mongodb in hashed format using python

296 views Asked by At

I am developing a web API using EVE REST Framework it contains a table which holds password of the users. When i send a 'get' request to mongodb the password is displayed in visible format. Can anyone tell me how to store values in mongodb which is not in a readable format(hashed format).

Thanks in advance!!!

1

There are 1 answers

0
ajsp On BEST ANSWER

You can use the hashlib library in python. You can pick from whichever algorithms you like, using md5 will look something like this:

import hashlib
password = 'abc123'
hash_object = hashlib.md5(password.encode())
print(hash_object.hexdigest())
>>>
e99a18c428cb38d5f260853678922e03

See the docs also, https://docs.python.org/2/library/hashlib.html