- String input = "password";
- String hash1 = Hash.hashSHA256asStringHex(input, 10);
- String hash2 = Hash.hashSHA256asStringHex(input, 10);
- String hash3 = Hash.hashSHA256asStringHex(input, 11);
-
- assertEquals(hash1, hash2);
- assertThat(hash1, not(equalTo(hash3)));
- }
-
- @Test
- public void isEqualTest() throws Exception {
- assertTrue(Hash.isEqual(same1, same2));
- assertFalse(Hash.isEqual(same1, different1));
- assertFalse(Hash.isEqual(same1, different2));
- }
-
- @Test
- public void compareToTest() throws Exception {
- assertEquals(0, Hash.compareTo(same1, same2));
- // different1 is rot13(same1), so the difference should be 13
- assertEquals(13, Hash.compareTo(same1, different1));
- assertEquals(-78, Hash.compareTo(same1, different2));
- }
-
- @Test
- public void toHexNo0xTest() throws Exception {
- assertEquals(uppersHexNo0x1, Hash.toHexNo0x(uppersDec.getBytes()));
- assertEquals(lowersHexNo0x1, Hash.toHexNo0x(lowersDec.getBytes()));
- assertEquals(numbersHexNo0x, Hash.toHexNo0x(numbersDec.getBytes()));
- }
-
- @Test
- public void toHexTest() throws Exception {
- assertEquals(uppersHex2, Hash.toHex(uppersDec.getBytes()));
- assertEquals(lowersHex, Hash.toHex(lowersDec.getBytes()));
- assertEquals(numbersHex, Hash.toHex(numbersDec.getBytes()));
- }
+ String input = "password";
+ String hash1 = Hash.hashSHA256asStringHex(input, 10);
+ String hash2 = Hash.hashSHA256asStringHex(input, 10);
+ String hash3 = Hash.hashSHA256asStringHex(input, 11);
+
+ assertEquals(hash1, hash2);
+ assertThat(hash1, not(equalTo(hash3)));
+ }
+
+ @Test
+ public void isEqualTest() throws Exception {
+ assertTrue(Hash.isEqual(same1, same2));
+ assertFalse(Hash.isEqual(same1, different1));
+ assertFalse(Hash.isEqual(same1, different2));
+ }
+
+ @Test
+ public void compareToTest() throws Exception {
+ assertEquals(0, Hash.compareTo(same1, same2));
+ // different1 is rot13(same1), so the difference should be 13
+ assertEquals(13, Hash.compareTo(same1, different1));
+ assertEquals(-78, Hash.compareTo(same1, different2));
+ }
+
+ @Test
+ public void toHexNo0xTest() throws Exception {
+ assertEquals(uppersHexNo0x1, Hash.toHexNo0x(uppersDec.getBytes()));
+ assertEquals(lowersHexNo0x1, Hash.toHexNo0x(lowersDec.getBytes()));
+ assertEquals(numbersHexNo0x, Hash.toHexNo0x(numbersDec.getBytes()));
+ }
+
+ @Test
+ public void toHexTest() throws Exception {
+ assertEquals(uppersHex2, Hash.toHex(uppersDec.getBytes()));
+ assertEquals(lowersHex, Hash.toHex(lowersDec.getBytes()));
+ assertEquals(numbersHex, Hash.toHex(numbersDec.getBytes()));
+ }