@Test(expected = UnsupportedOperationException.class) public void calculateUnsupportedHashTest() throws UnsupportedEncodingException { String in = "abc"; SecUtils.calculateHash("sha224", null, in.getBytes("UTF-8")); }
public static byte[] calculateHash(String algo, byte[] b1, byte[] b2) { byte[] m = mergeTwoArrays(b1, b2); if (algo.equals(HASH_SHA256)) { return DigestUtils.sha256(m); } else if (algo.equals(HASH_SHA1)) { return DigestUtils.sha1(m); } throw new UnsupportedOperationException(); }
SecUtils { public static byte[] calculateHash(String algo, byte[] b1, byte[] b2) { byte[] m = mergeTwoArrays(b1, b2); if (algo.equals(HASH_SHA256)) { return DigestUtils.sha256(m); } else if (algo.equals(HASH_SHA1)) { return DigestUtils.sha1(m); } throw new UnsupportedOperationException(); } }
SecUtils { public static byte[] calculateHash(String algo, byte[] b1, byte[] b2) { byte[] m = mergeTwoArrays(b1, b2); if (algo.equals(HASH_SHA256)) { return DigestUtils.sha256(m); } else if (algo.equals(HASH_SHA1)) { return DigestUtils.sha1(m); } throw new UnsupportedOperationException(); }  }
SecUtils { public static byte[] calculateHash(String algo, byte[] b1, byte[] b2) { byte[] m = mergeTwoArrays(b1, b2); if (algo.equals(HASH_SHA256)) { return DigestUtils.sha256(m); } else if (algo.equals(HASH_SHA1)) { return DigestUtils.sha1(m); } throw new UnsupportedOperationException(); }  static void main(String[] args); static EncodedKeySpec decodeKey(String key); static String encodeKey(String algo, PublicKey pk); static String encodeKey(String algo, PrivateKey pk); static EncodedKeySpec getKeySpecByFormat(String format, byte[] data); static String encodeBase64(byte[] data); static boolean validateKeyPair(String algo, PrivateKey privateKey, PublicKey publicKey); static KeyPair getKeyPair(String algo, String prKey, String pbKey); static KeyPair generateKeyPairFromPassword(String algo, String keygenMethod, String salt, String pwd); static KeyPair generateECKeyPairFromPassword(String keygenMethod, String salt, String pwd); static KeyPair generateEC256K1KeyPairFromPassword(String salt, String pwd); static KeyPair generateRandomEC256K1KeyPair(); static String signMessageWithKeyBase64(KeyPair keyPair, byte[] msg, String signAlgo, ByteArrayOutputStream out); static byte[] signMessageWithKey(KeyPair keyPair, byte[] msg, String signAlgo); static boolean validateSignature(KeyPair keyPair, byte[] msg, String sig); static boolean validateSignature(KeyPair keyPair, byte[] msg, String sigAlgo, byte[] signature); static byte[] calculateHash(String algo, byte[] b1, byte[] b2); static byte[] mergeTwoArrays(byte[] b1, byte[] b2); static String calculateHashWithAlgo(String algo, String salt, String msg); static String calculateHashWithAlgo(String algo, byte[] bts); static String formatHashWithAlgo(String algo, byte[] hash); static byte[] getHashBytes(String msg); static boolean validateHash(String hash, String salt, String msg); static byte[] decodeSignature(String digest); static String hexify(byte[] bytes); }
SecUtils { public static byte[] calculateHash(String algo, byte[] b1, byte[] b2) { byte[] m = mergeTwoArrays(b1, b2); if (algo.equals(HASH_SHA256)) { return DigestUtils.sha256(m); } else if (algo.equals(HASH_SHA1)) { return DigestUtils.sha1(m); } throw new UnsupportedOperationException(); }  static void main(String[] args); static EncodedKeySpec decodeKey(String key); static String encodeKey(String algo, PublicKey pk); static String encodeKey(String algo, PrivateKey pk); static EncodedKeySpec getKeySpecByFormat(String format, byte[] data); static String encodeBase64(byte[] data); static boolean validateKeyPair(String algo, PrivateKey privateKey, PublicKey publicKey); static KeyPair getKeyPair(String algo, String prKey, String pbKey); static KeyPair generateKeyPairFromPassword(String algo, String keygenMethod, String salt, String pwd); static KeyPair generateECKeyPairFromPassword(String keygenMethod, String salt, String pwd); static KeyPair generateEC256K1KeyPairFromPassword(String salt, String pwd); static KeyPair generateRandomEC256K1KeyPair(); static String signMessageWithKeyBase64(KeyPair keyPair, byte[] msg, String signAlgo, ByteArrayOutputStream out); static byte[] signMessageWithKey(KeyPair keyPair, byte[] msg, String signAlgo); static boolean validateSignature(KeyPair keyPair, byte[] msg, String sig); static boolean validateSignature(KeyPair keyPair, byte[] msg, String sigAlgo, byte[] signature); static byte[] calculateHash(String algo, byte[] b1, byte[] b2); static byte[] mergeTwoArrays(byte[] b1, byte[] b2); static String calculateHashWithAlgo(String algo, String salt, String msg); static String calculateHashWithAlgo(String algo, byte[] bts); static String formatHashWithAlgo(String algo, byte[] hash); static byte[] getHashBytes(String msg); static boolean validateHash(String hash, String salt, String msg); static byte[] decodeSignature(String digest); static String hexify(byte[] bytes); static final String SIG_ALGO_ECDSA; static final String ALGO_EC; static final String EC_256SPEC_K1; static final String KEYGEN_PWD_METHOD_1; static final String DECODE_BASE64; static final String HASH_SHA256; static final String HASH_SHA1; static final String KEY_BASE64; }