本文实例讲述了Java中RSA加密解密的实现方法。分享给大家供大家参考,具体如下:
public static void main(String[] args) throws Exception {
// TODO Auto-generated method stub
HashMap map = RSAUtils.getKeys();
//生成公钥和私钥
RSAPublicKey publicKey = (RSAPublicKey) map.get("public");
RSAPrivateKey privateKey = (RSAPrivateKey) map.get("private");
//模
String modulus = publicKey.getModulus().toString();
//公钥指数
String public_exponent = publicKey.getPublicExponent().toString();
//私钥指数
String private_exponent = privateKey.getPrivateExponent().toString();
//明文
String ming = "123456789";
//使用模和指数生成公钥和私钥
RSAPublicKey pubKey = RSAUtils.getPublicKey(modulus, public_exponent);
RSAPrivateKey priKey = RSAUtils.getPrivateKey(modulus, private_exponent);
//加密后的密文
St
如果觉得《java rsa 解密_Java中RSA加密解密的实现方法分析》对你有帮助,请点赞、收藏,并留下你的观点哦!