Use foreach where possible
This commit is contained in:
committed by
Josh Cummings
parent
7dc28ff376
commit
43737a56bd
@@ -34,11 +34,11 @@ public final class Hex {
|
||||
char[] result = new char[2 * nBytes];
|
||||
|
||||
int j = 0;
|
||||
for (int i = 0; i < nBytes; i++) {
|
||||
for (byte aByte : bytes) {
|
||||
// Char for top 4 bits
|
||||
result[j++] = HEX[(0xF0 & bytes[i]) >>> 4];
|
||||
result[j++] = HEX[(0xF0 & aByte) >>> 4];
|
||||
// Bottom 4
|
||||
result[j++] = HEX[(0x0F & bytes[i])];
|
||||
result[j++] = HEX[(0x0F & aByte)];
|
||||
}
|
||||
|
||||
return result;
|
||||
|
||||
@@ -122,10 +122,10 @@ public class BCryptTests {
|
||||
@Test
|
||||
public void testHashpw() {
|
||||
print("BCrypt.hashpw(): ");
|
||||
for (int i = 0; i < test_vectors.length; i++) {
|
||||
String plain = test_vectors[i][0];
|
||||
String salt = test_vectors[i][1];
|
||||
String expected = test_vectors[i][2];
|
||||
for (String[] test_vector : test_vectors) {
|
||||
String plain = test_vector[0];
|
||||
String salt = test_vector[1];
|
||||
String expected = test_vector[2];
|
||||
String hashed = BCrypt.hashpw(plain, salt);
|
||||
assertThat(expected).isEqualTo(hashed);
|
||||
print(".");
|
||||
@@ -176,9 +176,9 @@ public class BCryptTests {
|
||||
@Test
|
||||
public void testCheckpw_success() {
|
||||
print("BCrypt.checkpw w/ good passwords: ");
|
||||
for (int i = 0; i < test_vectors.length; i++) {
|
||||
String plain = test_vectors[i][0];
|
||||
String expected = test_vectors[i][2];
|
||||
for (String[] test_vector : test_vectors) {
|
||||
String plain = test_vector[0];
|
||||
String expected = test_vector[2];
|
||||
assertThat(BCrypt.checkpw(plain, expected)).isTrue();
|
||||
print(".");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user