S
sushant.bhatia
Hi All.
I'm using the NCrypto dll for RSA Encryption/Decryption
(http://sourceforge.net/projects/ncrypto/). My encryption code in .Net
is pretty simple. The dataToEncrypt length is 1024. The returned data
is 1161 in length.
public static byte[] EncryptRSA(string certFilePublic, byte[]
dataToEncrypt)
{
RSAParameters rsaParams = GetRSAPubKey(certFilePublic);
byte[] decryptedData = null;
try
{
decryptedData =
NCrypto.Security.Cryptography.CryptoHelper.Encrypt(dataToEncrypt,
rsaParams, false);
return decryptedData;
}
catch (Exception eer)
{
System.Windows.Forms.MessageBox.Show(eer.ToString());
return null;
}
}
The problem is when I try to decrypt I get a "System.ArgumentOutOfRange
Exception: Data length must be a multiple of 128. Parameter name:
cipherText".
The problem is that the encrypt function creates data that is 1161
bytes long which isn't a multiple of 128.
I've tried changing the data size going into the decrypt function but
the data returned is always a multiple of 129 and not 128.
Please HELP! I'm so stuck as to what to do. :-(
I'm using the NCrypto dll for RSA Encryption/Decryption
(http://sourceforge.net/projects/ncrypto/). My encryption code in .Net
is pretty simple. The dataToEncrypt length is 1024. The returned data
is 1161 in length.
public static byte[] EncryptRSA(string certFilePublic, byte[]
dataToEncrypt)
{
RSAParameters rsaParams = GetRSAPubKey(certFilePublic);
byte[] decryptedData = null;
try
{
decryptedData =
NCrypto.Security.Cryptography.CryptoHelper.Encrypt(dataToEncrypt,
rsaParams, false);
return decryptedData;
}
catch (Exception eer)
{
System.Windows.Forms.MessageBox.Show(eer.ToString());
return null;
}
}
The problem is when I try to decrypt I get a "System.ArgumentOutOfRange
Exception: Data length must be a multiple of 128. Parameter name:
cipherText".
The problem is that the encrypt function creates data that is 1161
bytes long which isn't a multiple of 128.
I've tried changing the data size going into the decrypt function but
the data returned is always a multiple of 129 and not 128.
Please HELP! I'm so stuck as to what to do. :-(