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

Class ToolRipeMD

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

RipeMD系列消息摘要组件 包含RipeMD128、RipeMD160、RipeMD256和RipeMD320共4种RipeMD系列算法 @author SeanDragon

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected