我正在为每个变量输入值以获取加密消息。出于测试目的,所有这些都是硬编码的。
这会?????
在它应该返回时返回值538 1729 1328 1328 2146
。有什么我放错了吗?这是我的代码遇到的唯一问题。
public static void main(String[] args){
int p = 61;
int q = 37;
int pq = p * q;
int phiPQ = (p - 1) * (q - 1);
int e = 7;
int d = 1543;
String message = encryptMsg("hello", pq, e);
System.out.println(message);
}
public static String encryptMsg(String msg, int pq, int e){
BigInteger bE = new BigInteger(Integer.toString(e));
BigInteger bPQ = new BigInteger(Integer.toString(pq));
String encryptedMsg = "";
for(int i = 0; i < msg.length(); i++){
BigInteger m = new BigInteger(Integer.toString(msg.charAt(i)));
BigInteger bC = m.modPow(bE, bPQ);
encryptedMsg += " " + (char)bC.intValue();
}
return encryptedMsg;
}