MCPcopy Create free account
hub / github.com/SeanDragon/protools / ToolMD

Class ToolMD

security/src/main/java/pro/tools/security/md/ToolMD.java:16–146  ·  view source on GitHub ↗

MD系列加密组件 Tiger、Whirlpool和GOST3411共3种算法 @author SeanDragon

Source from the content-addressed store, hash-verified

14 * @author SeanDragon
15 */
16public final class ToolMD {
17
18 private ToolMD() {
19 throw new UnsupportedOperationException("我是工具类,别初始化我。。。");
20 }
21
22
23 /**
24 * Tiger加密
25 *
26 * @param data
27 * 待加密数据
28 *
29 * @return byte[] 消息摘要
30 *
31 * @throws Exception
32 */
33 public static byte[] encodeTiger(byte[] data) throws NoSuchAlgorithmException {
34
35 // 加入BouncyCastleProvider支持
36 Security.addProvider(new BouncyCastleProvider());
37
38 // 初始化MessageDigest
39 MessageDigest md = MessageDigest.getInstance("Tiger");
40
41 // 执行消息摘要
42 return md.digest(data);
43 }
44
45 /**
46 * TigerHex加密
47 *
48 * @param data
49 * 待加密数据
50 *
51 * @return byte[] 消息摘要
52 *
53 * @throws Exception
54 */
55 public static String encodeTigerHex(byte[] data) throws NoSuchAlgorithmException {
56
57 // 执行消息摘要
58 byte[] b = encodeTiger(data);
59
60 // 做十六进制编码处理
61 return new String(Hex.encode(b));
62 }
63
64 /**
65 * Whirlpool加密
66 *
67 * @param data
68 * 待加密数据
69 *
70 * @return byte[] 消息摘要
71 *
72 * @throws Exception
73 */

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected