diff --git a/src/test/java/org/elasticsearch/shield/crypto/InternalCryptoServiceTests.java b/src/test/java/org/elasticsearch/shield/crypto/InternalCryptoServiceTests.java index 3939e314a34..3c184e89bf0 100644 --- a/src/test/java/org/elasticsearch/shield/crypto/InternalCryptoServiceTests.java +++ b/src/test/java/org/elasticsearch/shield/crypto/InternalCryptoServiceTests.java @@ -223,7 +223,12 @@ public class InternalCryptoServiceTests extends ElasticsearchTestCase { assertThat(Arrays.equals(encrypted, bytes), is(false)); int tamperedIndex = randomIntBetween(0, encrypted.length - 1); - encrypted[tamperedIndex] = randomByte(); + final byte untamperedByte = encrypted[tamperedIndex]; + byte tamperedByte = randomByte(); + while (tamperedByte == untamperedByte) { + tamperedByte = randomByte(); + } + encrypted[tamperedIndex] = tamperedByte; final byte[] decrypted = service.decrypt(encrypted); assertThat(Arrays.equals(bytes, decrypted), is(false)); }