aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/java/at')
-rw-r--r--src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java28
1 files changed, 19 insertions, 9 deletions
diff --git a/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java b/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
index fe0cfcb..ce46e68 100644
--- a/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
+++ b/src/main/java/at/knowcenter/wag/egov/egiz/tools/CodingHelper.java
@@ -197,22 +197,24 @@ public class CodingHelper
}
}
+ // dferbas
/**
- * This method builds an SHA-1 hash value of a given byte array.
+ * This method builds an hash value of a given byte array.
*
* @param data
* the byte array to build the hash value for
+ * @param hashAlg hash algorithm for {@link MessageDigest} e.g. "SHA-1"
* @return the calculated hash value as a byte array
* @see MessageDigest
*/
- public static byte[] buildDigest(byte[] data)
- {
- MessageDigest sha_1 = null;
+ public static byte[] buildDigest(byte[] data, String hashAlg)
+ {
+ MessageDigest digester = null;
try
{
- sha_1 = MessageDigest.getInstance("SHA-1");
- sha_1.update(data);
- return sha_1.digest();
+ digester = MessageDigest.getInstance(hashAlg);
+ digester.update(data);
+ return digester.digest();
}
catch (NoSuchAlgorithmException e)
{
@@ -220,11 +222,19 @@ public class CodingHelper
}
}
- public static byte[] buildDigest(DataSource input) throws IOException
+ // dferbas
+ /**
+ * This method builds an hash value of a given byte array.
+ * @param input
+ * @param hashAlg hashAlg hash algorithm for {@link MessageDigest} e.g. "SHA-1"
+ * @return the calculated hash value as a byte array
+ * @throws IOException
+ */
+ public static byte[] buildDigest(DataSource input, String hashAlg) throws IOException
{
// PERF: digesting needs data source.
byte [] data = DataSourceHelper.convertDataSourceToByteArray(input);
- return buildDigest(data);
+ return buildDigest(data, hashAlg);
}
/**