def test_encrypt_and_decrypt_unicode_in_string_type_unicode(self): my_value = u'hellü' assert_true(isinstance(my_value, unicode)) my_value_encrypted = encrypt(my_value) assert_true(isinstance(my_value_encrypted, bytes)) my_value_decrypted = decrypt(my_value_encrypted) assert_equal(my_value_decrypted, ensure_bytes(my_value)) my_value = u'찦차КЛМНО💁◕‿◕。)╱i̲̬͇̪͙n̝̗͕v̟̜̘̦͟o̶̙̰̠kè͚̮̺̪̹̱̤ ǝɹol' assert_true(isinstance(my_value, unicode)) my_value_encrypted = encrypt(my_value) my_value_decrypted = decrypt(my_value_encrypted) assert_true(isinstance(my_value_decrypted, bytes)) assert_equal(my_value_decrypted, ensure_bytes(my_value))
def test_encrypt_and_decrypt_no_unicode_in_string_type_unicode(self): my_value = u'hello' assert_true(isinstance(my_value, unicode)) my_value_encrypted = encrypt(my_value) assert_true(isinstance(my_value_encrypted, bytes)) my_value_decrypted = decrypt(my_value_encrypted) assert_true(isinstance(my_value_decrypted, bytes)) assert_equal(my_value_decrypted, ensure_bytes(my_value))
def test_encryption(): private_string = 'p4ssw0rd' # Encrypted string is obfuscated encrypted_string = encrypt(private_string) assert_not_in(private_string, encrypted_string) # Original string can be recovered decrypted_string = decrypt(encrypted_string) assert_equal(decrypted_string, private_string)