RSA 해독 문제RSA 암호 해독 문제 C#
C# RSA 프로그램에 문제가 있습니다. 제대로 해독하지 않습니다. d =(e^-1)%phiN
을 할당하고 내 암호문에 d를 적용하면 어리석은 10 진수 응답이 표시됩니다. 전체 숫자가 나와야합니다. 제 수학에 문제가 있다고 생각합니다. 조언 있니? 자세한 내용이나 나머지 코드가 필요하면 질문하십시오. 또한이 코드를 개선하는 데 사용할 수있는 패딩 구성표가 있습니까? 현재이 코드는 주파수 분석에 취약합니다.
protected void decryptRSA(object sender, EventArgs ev)
{
double p = (double)Convert.ToInt64(P.Text);//I use 123 for testing
double q = (double)Convert.ToInt64(Q.Text);//127
double e = (double)Convert.ToInt64(E.Text);//133
double phiN = (p-1)*(q-1);
double n = p*q;
double d = Math.Pow(e, -1D);
d = d%phiN;
string cipherStr = outputBuffer.Text;
double[] cipherTextDouble = new double[100];
string[]plainText = new string[cipherTextDouble.Length];
cipherTextDouble = parser(cipherStr, 'D');
for(int slot = 0; slot<cipherTextDouble.Length; slot++)
{
cipherTextDouble[slot] = (double)(Math.Pow((double)cipherTextDouble[slot],(double)d)%n);
}
for(int slot = 0; slot<cipherTextDouble.Length; slot++)
{
inputBuffer.Text += Convert.ToChar(cipherTextDouble[slot]) + ' ';//the spot were it dies
//it doesn't like to convert from a decimal like 1.75 to a char. Of course I should never get a decimal like 1.75, which is the problem
}
}
두 배를 사용하지 마십시오. –