def it_encrypts_items(self): encrypted_key = self.get_key() decrypted_key = crypto.decrypt_key(encrypted_key, 'masterpassword123') decrypted_item = self.get_item() decrypted_item['encrypted'] = {'fields': [{'value': 'foo'}, {'value': 'bar'}, {'ball': '⚽'}]} encrypted_item = crypto.encrypt_item(decrypted_item, decrypted_key) redecrypted_item = crypto.decrypt_item(encrypted_item, decrypted_key) assert redecrypted_item['encrypted']['fields'][0]['value'] == 'foo' assert redecrypted_item['encrypted']['fields'][1]['value'] == 'bar'
def it_encrypts_items(self): encrypted_key = self.get_key() decrypted_key = crypto.decrypt_key(encrypted_key, 'masterpassword123') decrypted_item = self.get_item() decrypted_item['encrypted'] = { 'fields': [{ 'value': 'foo' }, { 'value': 'bar' }, { 'ball': '⚽' }] } encrypted_item = crypto.encrypt_item(decrypted_item, decrypted_key) redecrypted_item = crypto.decrypt_item(encrypted_item, decrypted_key) assert redecrypted_item['encrypted']['fields'][0]['value'] == 'foo' assert redecrypted_item['encrypted']['fields'][1]['value'] == 'bar'
def _encrypt_item(self, item): return crypto.encrypt_item(item, self._get_key_for_item(item))