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
Asked
Active
Viewed 1,510 times
4 Answers
1
# To save it:
with open('file-to-save-password', 'bw') as f:
f.write( b'&Ti\xcfK\x15\xe2\x19\x0c')
# To read it:
with open('file-to-save-password', 'br') as f:
print(f.read())
0
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')

Zach Gates
- 4,045
- 1
- 27
- 51
0
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.

Jordan Gregory
- 23
- 9
0
python persistence is useful here. e.g:
import shelve
with shelve.open('secrets') as db:
db['password'] = b'&Ti\xcfK\x15\xe2\x19\x0c'

Rich Tier
- 9,021
- 10
- 48
- 71