]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-2291 lower-case hash
authorSimon Brandhof <simon.brandhof@gmail.com>
Sun, 10 Feb 2013 18:09:45 +0000 (19:09 +0100)
committerSimon Brandhof <simon.brandhof@gmail.com>
Sun, 10 Feb 2013 18:12:27 +0000 (19:12 +0100)
sonar-home/src/main/java/org/sonar/home/cache/FileHashes.java
sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java

index 9a44ae6fa58dab74122a474ba5ea95a0407c9b81..0ce1d0455bcf11402f2d4c770274648f8b179359 100644 (file)
@@ -74,6 +74,6 @@ public class FileHashes {
 
   static String toHex(byte[] bytes) {
     BigInteger bi = new BigInteger(1, bytes);
-    return String.format("%0" + (bytes.length << 1) + "X", bi);
+    return String.format("%0" + (bytes.length << 1) + "x", bi);
   }
 }
\ No newline at end of file
index ff6c01c7a3ebd90a5a7b24c3a1130679792751f2..e7d7ed98d76ec928fc8fd8f04ec816f2f121d277 100644 (file)
@@ -47,27 +47,27 @@ public class FileHashesTest {
 
   @Test
   public void test_md5_hash() {
-    assertThat(hash("sonar")).isEqualTo("D85E336D61F5344395C42126FAC239BC");
+    assertThat(hash("sonar")).isEqualTo("d85e336d61f5344395c42126fac239bc");
 
     // compare results with commons-codec
     for (int index = 0; index < 100; index++) {
       String random = randomString();
       assertThat(hash(random)).as(random).isEqualTo(
-        DigestUtils.md5Hex(random).toUpperCase()
+        DigestUtils.md5Hex(random).toLowerCase()
       );
     }
   }
 
   @Test
   public void test_toHex() {
-    // upper-case
-    assertThat(FileHashes.toHex("aloa_bi_bop_a_loula".getBytes())).isEqualTo("616C6F615F62695F626F705F615F6C6F756C61");
+    // lower-case
+    assertThat(FileHashes.toHex("aloa_bi_bop_a_loula".getBytes())).isEqualTo("616c6f615f62695f626f705f615f6c6f756c61");
 
     // compare results with commons-codec
     for (int index = 0; index < 100; index++) {
       String random = randomString();
       assertThat(FileHashes.toHex(random.getBytes())).as(random).isEqualTo(
-        Hex.encodeHexString(random.getBytes()).toUpperCase()
+        Hex.encodeHexString(random.getBytes()).toLowerCase()
       );
     }
   }