0
点赞
收藏
分享

微信扫一扫

hutool对称加密

加密逻辑


public static void main(String[] args) {
// 1. 内部先初始化静态代码块 设置非对称加密的对象 新建对象的父类会自动生成默认的公钥和私钥
RSA rsa = new RSA();
// 下面两行代码作用不大 KeyType.PublicKey 判断公钥为空的时候会自动生成
PrivateKey privateKey = rsa.getPrivateKey();
PublicKey publicKey = rsa.getPublicKey();
String s = rsa.encryptBcd("hello world", KeyType.PublicKey);
byte[] decrypt = rsa.decrypt(s, KeyType.PrivateKey);
System.out.println(StrUtil.str(decrypt,CharsetUtil.UTF_8));
}


举报

相关推荐

0 条评论