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

Method initKey

security/src/main/java/pro/tools/security/ToolDH.java:73–97  ·  view source on GitHub ↗

初始化甲方密钥 @return Map 甲方密钥Map @throws Exception

()

Source from the content-addressed store, hash-verified

71 * @throws Exception
72 */
73 public static Map<String, Object> initKey() throws NoSuchAlgorithmException {
74
75 // 实例化密钥对生成器
76 KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance(KEY_ALGORITHM);
77
78 // 初始化密钥对生成器
79 keyPairGenerator.initialize(KEY_SIZE);
80
81 // 生成密钥对
82 KeyPair keyPair = keyPairGenerator.generateKeyPair();
83
84 // 甲方公钥
85 DHPublicKey publicKey = (DHPublicKey) keyPair.getPublic();
86
87 // 甲方私钥
88 DHPrivateKey privateKey = (DHPrivateKey) keyPair.getPrivate();
89
90 // 将密钥对存储在Map中
91 Map<String, Object> keyMap = Maps.newHashMapWithExpectedSize(2);
92
93 keyMap.put(PUBLIC_KEY, publicKey);
94 keyMap.put(PRIVATE_KEY, privateKey);
95
96 return keyMap;
97 }
98
99 /**
100 * 初始化乙方密钥

Callers

nothing calls this directly

Calls 3

getInstanceMethod · 0.80
generateKeyPairMethod · 0.80
getParamsMethod · 0.80

Tested by

no test coverage detected