Skip to content

Commit

Permalink
Update test
Browse files Browse the repository at this point in the history
  • Loading branch information
kschulst committed Apr 11, 2023
1 parent 372e8df commit 7f1aa9d
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions src/test/java/no/ssb/crypto/tink/fpe/FpeFf3Test.java
Original file line number Diff line number Diff line change
Expand Up @@ -182,13 +182,14 @@ void ff31_encrypt_decrypt_with_different_string_encoding() throws Exception {
byte[] latin1Plaintext = plaintextStr.getBytes(StandardCharsets.ISO_8859_1);
byte[] latin1Ciphertext = fpe.encrypt(latin1Plaintext, paramsLatin1);
byte[] latin1PlaintextRestored = fpe.decrypt(latin1Ciphertext, paramsLatin1);
assertThat(latin1Plaintext).isEqualTo(latin1PlaintextRestored);

// Ensure the original and restored plaintexts match, regardless of the encoding used.
assertThat(utf8PlaintextRestored).isEqualTo(utf8PlaintextRestored);
assertThat(latin1PlaintextRestored).isEqualTo(latin1Plaintext);

// Ciphertexts will be different if using different encodings
assertThat(utf8Ciphertext).isNotEqualTo(latin1Ciphertext);

// Ensure the original and restored plaintexts match, regardless of the encoding used.
assertThat(plaintextStr).isEqualTo(new String(utf8PlaintextRestored, StandardCharsets.UTF_8));
assertThat(plaintextStr).isEqualTo(new String(latin1PlaintextRestored, StandardCharsets.ISO_8859_1));
}

}

0 comments on commit 7f1aa9d

Please sign in to comment.