Example #1
0
    def test_public_key_encryption(self):
        """ Verify that encryption matches a known encrypted string """

        PLAINTEXT_MESSAGE = 'This is a secret message ~ for your eyes only'
        ENCRYPTED_MESSAGE = 'wM9rJnv-b5C5S8hwIm062vCpOkA8DbVJ90g-pVWMCufEZfRsrr9yub83Mxx-lO8SkyuX3F5gtqn9DWonypSNHNXyBl9_j2hDci1SRpE4jm4KLX_LLw=='

        public_key_encryptor = PublicKeyEncryptor(RECIPIENT_PUBLIC_KEY)

        encrypted_message = public_key_encryptor.encrypt(PLAINTEXT_MESSAGE, nonce=KNOWN_NONCE)

        self.assertEqual(encrypted_message, ENCRYPTED_MESSAGE)
    def test_public_key_encryption(self):
        """ Verify that encryption matches a known encrypted string """

        PLAINTEXT_MESSAGE = "This is a secret message ~ for your eyes only"
        ENCRYPTED_MESSAGE = "wM9rJnv-b5C5S8hwIm062vCpOkA8DbVJ90g-pVWMCufEZfRsrr9yub83Mxx-lO8SkyuX3F5gtqn9DWonypSNHNXyBl9_j2hDci1SRpE4jm4KLX_LLw=="

        public_key_encryptor = PublicKeyEncryptor(RECIPIENT_PUBLIC_KEY)

        encrypted_message = public_key_encryptor.encrypt(PLAINTEXT_MESSAGE, nonce=KNOWN_NONCE)

        self.assertEqual(encrypted_message, ENCRYPTED_MESSAGE)
Example #3
0
    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)