Return rsa.sign(message.encode('utf8'), key, 'SHA-1') Return rsa.decrypt(ciphertext, key).decode('utf8') Return rsa.encrypt(message.encode('utf8'), key)
Return APubKey, APrivKey, BPubKey, BPrivKey With open('keys/BPrivKey.pem', 'rb') as p:īPrivKey = _pkcs1(p.read()) With open('keys/BPubKey.pem', 'rb') as p:īPubKey = _pkcs1(p.read()) With open('keys/APrivKey.pem', 'rb') as p:ĪPrivKey = _pkcs1(p.read()) With open('keys/APubKey.pem', 'rb') as p:ĪPubKey = _pkcs1(p.read()) With open('keys/BPrivKey.pem', 'wb') as p: With open('keys/BPubKey.pem', 'wb') as p: With open('keys/APrivKey.pem', 'wb') as p: With open('keys/APubKey.pem', 'wb') as p: (publicKey, privateKey) = rsa.newkeys(1024) I am trying to implement a Symmetric-key agreement scheme using public-key cryptography between multiple clients via socket communication and I have been testing the encryption and decryption functionality.