i have encrypted a password and the result is like this: b'&Ti\xcfK\x15\xe2\x19\x0c' i want to save it to an config file and reload it so i can decrypt it and i can use it again as password
Python write b'xxxx' to config and read it
1.5k views Asked by bhmth At
4
There are 4 answers
0
On
Take a look at Python's open
builtin function.
with open('foo.txt', 'wb') as f:
f.write(b'&Ti\xcfK\x15\xe2\x19\x0c')
0
On
You can do something like this:
# to write the file
cryptpw = "your encrypted password"
config = open("/path/to/config/file/pw.config","w")
config.write(cryptpw)
config.close()
# to reopen it
config = open("/path/to/config/file/pw.config","r")
print(config.read())
config.close()
It's up to you what you do with the contents of that file, i just chose to print it.
0
On
python persistence is useful here. e.g:
import shelve
with shelve.open('secrets') as db:
db['password'] = b'&Ti\xcfK\x15\xe2\x19\x0c'