{\r
return getDigest(bytes, "SHA-1");\r
}\r
+\r
+\r
+ /**\r
+ * Calculates the SHA256 of the string.\r
+ *\r
+ * @param text\r
+ * @return sha256 of the string\r
+ */\r
+ public static String getSHA256(String text)\r
+ {\r
+ return getDigest(text, "SHA-256");\r
+ }\r
+\r
+ /**\r
+ * Calculates the SHA256 of the byte array.\r
+ *\r
+ * @param bytes\r
+ * @return sha256 of the byte array\r
+ */\r
+ public static String getSHA256(byte[] bytes)\r
+ {\r
+ return getDigest(bytes, "SHA-256");\r
}\r
\r
/**\r
StringUtils.getSHA1("blob 16\000what is up, doc?"));\r
}\r
\r
+ @Test\r
+ public void testSHA256() throws Exception {\r
+ assertEquals("badf72532e259f2b67a40475486c7e71bf48bc71d7b0d43d8e99acfb3ac24e1b",\r
+ StringUtils.getSHA256("margaret@london.uk"));\r
+ }\r
+\r
@Test\r
public void testMD5() throws Exception {\r
assertEquals("77fb8d95331f0d557472f6776d3aedf6",\r