From f2db48bd6fa9a0e5eaccaf696bc0e2dcba46bfe6 Mon Sep 17 00:00:00 2001 From: Simon Brandhof Date: Sun, 10 Feb 2013 19:09:45 +0100 Subject: SONAR-2291 lower-case hash --- sonar-home/src/main/java/org/sonar/home/cache/FileHashes.java | 2 +- .../src/test/java/org/sonar/home/cache/FileHashesTest.java | 10 +++++----- 2 files changed, 6 insertions(+), 6 deletions(-) (limited to 'sonar-home/src') 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() ); } } -- cgit v1.2.3