def test_public_key_decryption(self): """ Verify that decryption matches a known plaintext string """ ENCRYPTED_MESSAGE = 'wM9rJnv-b5C5S8hwIm062vCpOkA8DbVJ6JJWEScFHnMqSPG63QAcCL83Mxx-lO8SkyuS3E9r866tBWw92JnKFJD_VVh3mA==' PLAINTEXT_MESSAGE = 'This is a very special message' private_key_decryptor = PrivateKeyDecryptor(RECIPIENT_PRIVATE_KEY) decrypted_message = private_key_decryptor.decrypt(ENCRYPTED_MESSAGE) self.assertEqual(PLAINTEXT_MESSAGE, decrypted_message)
def test_public_key_decryption(self): """ Verify that decryption matches a known plaintext string """ ENCRYPTED_MESSAGE = ( "wM9rJnv-b5C5S8hwIm062vCpOkA8DbVJ6JJWEScFHnMqSPG63QAcCL83Mxx-lO8SkyuS3E9r866tBWw92JnKFJD_VVh3mA==" ) PLAINTEXT_MESSAGE = "This is a very special message" private_key_decryptor = PrivateKeyDecryptor(RECIPIENT_PRIVATE_KEY) decrypted_message = private_key_decryptor.decrypt(ENCRYPTED_MESSAGE) self.assertEqual(PLAINTEXT_MESSAGE, decrypted_message)
def test_public_key_encryption_and_decryption(self): """ Verify that encryption with a given password matches decryption with the same password """ PLAINTEXT_MESSAGE = 'This is another cool message' public_key_encryptor = PublicKeyEncryptor(RECIPIENT_PUBLIC_KEY) encrypted_message = public_key_encryptor.encrypt(PLAINTEXT_MESSAGE) private_key_decryptor = PrivateKeyDecryptor(RECIPIENT_PRIVATE_KEY) decrypted_message = private_key_decryptor.decrypt(encrypted_message) self.assertEqual(PLAINTEXT_MESSAGE, decrypted_message)
def test_public_key_encryption_and_decryption(self): """ Verify that encryption with a given password matches decryption with the same password """ PLAINTEXT_MESSAGE = "This is another cool message" public_key_encryptor = PublicKeyEncryptor(RECIPIENT_PUBLIC_KEY) encrypted_message = public_key_encryptor.encrypt(PLAINTEXT_MESSAGE) private_key_decryptor = PrivateKeyDecryptor(RECIPIENT_PRIVATE_KEY) decrypted_message = private_key_decryptor.decrypt(encrypted_message) self.assertEqual(PLAINTEXT_MESSAGE, decrypted_message)