代码拉取完成,页面将自动刷新
import java.security.*;
import java.security.spec.*;
import javax.crypto.*;
import javax.crypto.spec.*;
import javax.crypto.interfaces.*;
import java.security.interfaces.*;
import java.math.*;
import java.io.*;
public class Dec_RSA {
public static void main(String args[]) throws Exception {
//读取密文
BufferedReader in =
new BufferedReader(new InputStreamReader(
new FileInputStream("Enc_RSA.dat")));
String ctext = in.readLine();
BigInteger c = new BigInteger(ctext);
//读取私钥
FileInputStream f = new FileInputStream("Skey_RSA_priv.dat");
ObjectInputStream b = new ObjectInputStream(f);
RSAPrivateKey prk = (RSAPrivateKey) b.readObject();
BigInteger d = prk.getPrivateExponent();
//获取私钥参数及解密
BigInteger n = prk.getModulus();
System.out.println("d= " + d);
System.out.println("n= " + n);
BigInteger m = c.modPow(d, n);
//显示解密结果
System.out.println("m= " + m);
byte[] mt = m.toByteArray();
System.out.println("PlainText is ");
for (int i = 0; i < mt.length; i++) {
System.out.print((char) mt[i]);
}
}
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。