public AjaxResult getKey(String appId) {
KeyPair pair = SecureUtil.generateKeyPair("RSA");
PrivateKey aPrivate = pair.getPrivate();
PublicKey aPublic = pair.getPublic();
String key = "third:key:" + RandomUtil.randomString(10);
Map<String, String> keys = new HashMap<>();
keys.put("publicKey", Base64.encode(aPublic.getEncoded()));
keys.put("privateKey", Base64.encode(aPrivate.getEncoded()));
redisCache.setCacheMap(key, keys);
redisCache.expire(key, 60, TimeUnit.SECONDS);
return AjaxResult.success().put("key", key).put("publicKey", Base64.encode(aPublic.getEncoded()));
}
Hutool非对称加密
最新推荐文章于 2024-05-22 15:38:25 发布