def test_encrypt_and_decrypt_should_be_reversible(self): # setup msg = "This is my party." encrypted_msg = encrypt(TEST_KEY, msg, base64_encode=False) decrypted_msg = decrypt(TEST_KEY, encrypted_msg, base64_decode=False) self.assertEqual(msg, decrypted_msg)
def _get_access_token_record(): client = boto3.client('dynamodb') response = client.get_item( TableName='GDriveCreds', Key={ 'Id': { 'N': '1' }, }, ConsistentRead=True) value = json.loads(secrets.decrypt(response['Item']['Record']['S'])) return value['token_expiry'], value['access_token'], value['refresh_token']
def test_encrypt_and_decrypt_should_optionally_encode_and_decode_in_b64(self): # setup msg = "This is my verrry fun message." encrypted_msg = encrypt(TEST_KEY, msg, base64_encode=True) # Should not raise TypeError base64.b64decode(encrypted_msg) decrypted_msg = decrypt(TEST_KEY, encrypted_msg, base64_decode=True) self.assertEqual(msg, decrypted_msg)
def test_encrypt_decrypt(self): keys = secrets.generate_keys() public = keys["public"] private = keys["private"] self.assertEqual( secrets.decrypt(secrets.encrypt('foo', public), private), 'foo')