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

Method initKey

security/src/main/java/pro/tools/security/ToolRSA.java:207–230  ·  view source on GitHub ↗

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

()

Source from the content-addressed store, hash-verified

205 * @throws Exception
206 */
207 public static Map<String, Object> initKey() throws NoSuchAlgorithmException {
208 // 实例化密钥对生成器
209 KeyPairGenerator keyPairGen = KeyPairGenerator.getInstance(KEY_ALGORITHM);
210
211 // 初始化密钥对生成器
212 keyPairGen.initialize(KEY_SIZE);
213
214 // 生成密钥对
215 KeyPair keyPair = keyPairGen.generateKeyPair();
216
217 // 公钥
218 RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic();
219
220 // 私钥
221 RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
222
223 // 封装密钥
224 Map<String, Object> keyMap = Maps.newHashMapWithExpectedSize(2);
225
226 keyMap.put(PUBLIC_KEY, publicKey);
227 keyMap.put(PRIVATE_KEY, privateKey);
228
229 return keyMap;
230 }
231
232}

Callers

nothing calls this directly

Calls 2

getInstanceMethod · 0.80
generateKeyPairMethod · 0.80

Tested by

no test coverage detected