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

Method initKey

security/src/main/java/pro/tools/security/ToolDSA.java:139–160  ·  view source on GitHub ↗

生成密钥 @return 密钥对象 @throws Exception

()

Source from the content-addressed store, hash-verified

137 * @throws Exception
138 */
139 public static Map<String, Object> initKey() throws NoSuchAlgorithmException {
140 // 初始化密钥对儿生成器
141 KeyPairGenerator keygen = KeyPairGenerator.getInstance(ALGORITHM);
142
143 // 实例化密钥对儿生成器
144 keygen.initialize(KEY_SIZE, new SecureRandom());
145
146 // 实例化密钥对儿
147 KeyPair keys = keygen.genKeyPair();
148
149 DSAPublicKey publicKey = (DSAPublicKey) keys.getPublic();
150
151 DSAPrivateKey privateKey = (DSAPrivateKey) keys.getPrivate();
152
153 // 封装密钥
154 Map<String, Object> map = Maps.newHashMapWithExpectedSize(2);
155
156 map.put(PUBLIC_KEY, publicKey);
157 map.put(PRIVATE_KEY, privateKey);
158
159 return map;
160 }
161
162 /**
163 * 取得私钥

Callers

nothing calls this directly

Calls 1

getInstanceMethod · 0.80

Tested by

no test coverage detected