Answer the question
In order to leave comments, you need to log in
RSA encryption keys. I write the key to the database and convert it to the string type, and how to encrypt it after that?
(pubkey, privkey) = rsa.newkeys(512)
cur.execute("INSERT INTO persons (domain, key ) VALUES (%s,%s)", (domain, str(pubkey)))
conn.commit()
Answer the question
In order to leave comments, you need to log in
After reading the key from the database, before using it, convert the string to bytes
pubkey.encode()
But before saving to the database pubkey.decode() instead of casting to a string - it will be more correct.
It is assumed that your database is utf8-coloured
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question