0

Here is my encrypted string:

b'pN\xe89\xd8\x83x\x9d\ts\xdb\x91\x87\xb4L\x1bU\xf2\x1fQqL\rz\x8d\xbb\xd0J\x99\xb7\xc0\x8a\x17n@\xdc\x16s\xfaf\x17\x00:\x0f\x86'

How do I convert this into a String that can be written to ConfigParser

later, read this string and convert it back to the correct data type for used for encryption?

encrypted username are of type:<class 'nacl.utils.EncryptedMessage'>
Maarten Bodewes
  • 90,524
  • 13
  • 150
  • 263
yopines
  • 49
  • 5
  • 4
    There are a number of encodings that can represent binary data (what you have) using a subset of ASCII runes - base64 is probably the most common. – Luke Joshua Park Dec 05 '19 at 20:51
  • I tried that encrypted_raw = base64.b64encode(encrypted) and get an error: AttributeError: 'bytes' object has no attribute 'items' – yopines Dec 05 '19 at 20:54
  • I think you need to do `b(b'pN\xe89\xd8\x83x\x9d\ts\xdb\x91\x87\xb4L\x1bU\xf2\x1fQqL\rz\x8d\xbb\xd0J\x99\xb7\xc0\x8a\x17n@\xdc\x16s\xfaf\x17\x00:\x0f\x86')` to convert your string to a `bytes` object, can you check? So that's calling the function `b()` on it. – Maarten Bodewes Dec 08 '19 at 21:24
  • 1
    @Maarten-reinstateMonica: at least in python3 literals of the form b'' are already `bytes` objects. – President James K. Polk Dec 26 '19 at 17:32
  • I will try that, and let you know. Thanks – yopines Dec 26 '19 at 17:34

0 Answers0