Search code examples
pythonencryptionpasswordsconfigparser

Python write b'xxxx' to config and read it


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


Solution

  • # 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())