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
}
}
ダブルを使用しないでください。 –