FileInputStream privateStream = new FileInputStream("/privateKey");
byte[] privateKeyByte = new byte[privateStream.available()];
privateStream.read(privateKeyByte);
String privateKeyAll = new String(privateKeyByte);
String privateKey = privateKeyAll.replace("-----BEGIN PRIVATE KEY-----","").replace("-----END PRIVATE KEY-----","");
FileInputStream publicStream = new FileInputStream("/publicKey");
byte[] publicKeyByte = new byte[publicStream.available()];
publicStream.read(publicKeyByte);
String publicKeyAll = new String(publicKeyByte);
String publicKey = publicKeyAll.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "");
byte[] publicKey64 = Base64.decodeBase64(publicKey);
byte[] privateKey64 = Base64
RSA本地密钥读取(PEM格式base64解码)
最新推荐文章于 2024-07-25 16:26:56 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)