diff options
author | 2018-07-12 11:02:18 +0100 | |
---|---|---|
committer | 2018-07-12 11:02:18 +0100 | |
commit | 194adee686ebb90488f739f2c637f6cb3def94d5 (patch) | |
tree | e0b5ddf0a188c559f81a228f124c246ddfdab648 /src/main/java/org/onap/crud/util | |
parent | d5322dbd0fa1e32d543b24824a28d6bf0a0b5497 (diff) |
Fix sonar violations
Issue-ID: AAI-1190
Change-Id: I72894665b288416069d3c2eb84185fcc303976f7
Signed-off-by: Sotiropoulos, Ioannis (is948x) <Ioannis.Sotiropoulos@amdocs.com>
Diffstat (limited to 'src/main/java/org/onap/crud/util')
-rw-r--r-- | src/main/java/org/onap/crud/util/HashGenerator.java | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/src/main/java/org/onap/crud/util/HashGenerator.java b/src/main/java/org/onap/crud/util/HashGenerator.java index 02558fa..24f1823 100644 --- a/src/main/java/org/onap/crud/util/HashGenerator.java +++ b/src/main/java/org/onap/crud/util/HashGenerator.java @@ -26,6 +26,7 @@ import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; + /** * Generates a sha 256 hash */ @@ -38,8 +39,9 @@ public class HashGenerator { } /** - * Generates a SHA 256 hash as a hexadecimal string for the inputs. - * Calls toString on the input objects to convert into a byte stream. + * Generates a SHA 256 hash as a hexadecimal string for the inputs. Calls toString on the input + * objects to convert into a byte stream. + * * @param values * @return SHA 256 hash of the inputs as a hexadecimal string. * @throws IOException @@ -48,13 +50,14 @@ public class HashGenerator { byte[] bytes = convertToBytes(values); byte[] digest = messageDigest.digest(bytes); StringBuilder result = new StringBuilder(); - for (byte byt : digest) result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1)); + for (byte byt : digest) { + result.append(Integer.toString((byt & 0xff) + 0x100, 16).substring(1)); + } return result.toString(); } private byte[] convertToBytes(Object... values) throws IOException { - try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); - ObjectOutput out = new ObjectOutputStream(bos)) { + try (ByteArrayOutputStream bos = new ByteArrayOutputStream(); ObjectOutput out = new ObjectOutputStream(bos)) { for (Object object : values) { out.writeObject(object.toString()); } @@ -62,4 +65,4 @@ public class HashGenerator { } } -}
\ No newline at end of file +} |