コード例 #1
0
ファイル: client.py プロジェクト: wendy-king/x7_client_venv
 def encrypt_metadata(self, image_metadata):
     if (self.metadata_encryption_key is not None
         and 'location' in image_metadata.keys()
         and image_metadata['location'] is not None):
         location = crypt.urlsafe_encrypt(self.metadata_encryption_key,
                                          image_metadata['location'], 64)
         image_metadata['location'] = location
     return image_metadata
コード例 #2
0
 def encrypt_metadata(self, image_metadata):
     if (self.metadata_encryption_key is not None
             and 'location' in image_metadata.keys()
             and image_metadata['location'] is not None):
         location = crypt.urlsafe_encrypt(self.metadata_encryption_key,
                                          image_metadata['location'], 64)
         image_metadata['location'] = location
     return image_metadata
コード例 #3
0
    def test_encryption(self):
        # Check that original plaintext and unencrypted ciphertext match
        # Check keys of the three allowed lengths
        key_list = ["1234567890abcdef", "12345678901234567890abcd", "1234567890abcdef1234567890ABCDEF"]
        plaintext_list = [""]
        blocksize = 64
        for i in range(3 * blocksize):
            plaintext_list.append(os.urandom(i))

        for key in key_list:
            for plaintext in plaintext_list:
                ciphertext = crypt.urlsafe_encrypt(key, plaintext, blocksize)
                self.assertTrue(ciphertext != plaintext)
                text = crypt.urlsafe_decrypt(key, ciphertext)
                self.assertTrue(plaintext == text)
コード例 #4
0
    def test_encryption(self):
        # Check that original plaintext and unencrypted ciphertext match
        # Check keys of the three allowed lengths
        key_list = [
            "1234567890abcdef", "12345678901234567890abcd",
            "1234567890abcdef1234567890ABCDEF"
        ]
        plaintext_list = ['']
        blocksize = 64
        for i in range(3 * blocksize):
            plaintext_list.append(os.urandom(i))

        for key in key_list:
            for plaintext in plaintext_list:
                ciphertext = crypt.urlsafe_encrypt(key, plaintext, blocksize)
                self.assertTrue(ciphertext != plaintext)
                text = crypt.urlsafe_decrypt(key, ciphertext)
                self.assertTrue(plaintext == text)