diff options
Diffstat (limited to 'src/main/java/org/onap/crud/util/HashGenerator.java')
-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 +} |