diff options
author | Simon Brandhof <simon.brandhof@gmail.com> | 2013-02-10 19:09:45 +0100 |
---|---|---|
committer | Simon Brandhof <simon.brandhof@gmail.com> | 2013-02-10 19:12:27 +0100 |
commit | f2db48bd6fa9a0e5eaccaf696bc0e2dcba46bfe6 (patch) | |
tree | 7c5add4492ddaa4772cd425081638b7cf41fab01 /sonar-home/src | |
parent | abb950335228f128939a69a52bf090782623459f (diff) | |
download | sonarqube-f2db48bd6fa9a0e5eaccaf696bc0e2dcba46bfe6.tar.gz sonarqube-f2db48bd6fa9a0e5eaccaf696bc0e2dcba46bfe6.zip |
SONAR-2291 lower-case hash
Diffstat (limited to 'sonar-home/src')
-rw-r--r-- | sonar-home/src/main/java/org/sonar/home/cache/FileHashes.java | 2 | ||||
-rw-r--r-- | sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java | 10 |
2 files changed, 6 insertions, 6 deletions
diff --git a/sonar-home/src/main/java/org/sonar/home/cache/FileHashes.java b/sonar-home/src/main/java/org/sonar/home/cache/FileHashes.java index 9a44ae6fa58..0ce1d0455bc 100644 --- a/sonar-home/src/main/java/org/sonar/home/cache/FileHashes.java +++ b/sonar-home/src/main/java/org/sonar/home/cache/FileHashes.java @@ -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 diff --git a/sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java b/sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java index ff6c01c7a3e..e7d7ed98d76 100644 --- a/sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java +++ b/sonar-home/src/test/java/org/sonar/home/cache/FileHashesTest.java @@ -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() ); } } |