HighTechTalks DotNet Forums  

Re: NCrypto Encryption & Decryption

CSharp microsoft.public.dotnet.languages.csharp


Discuss Re: NCrypto Encryption & Decryption in the CSharp forum.



Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old   
Kevin
 
Posts: n/a

Default Re: NCrypto Encryption & Decryption - 05-02-2005 , 07:40 PM






please try also another Crypto DLL:
www.aspsimply.com/vbnet/protool.aspx




<sushant.bhatia (AT) gmail (DOT) com> wrote

Quote:
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. :-(




Reply With Quote
  #2  
Old   
Sushant Bhatia
 
Posts: n/a

Default Re: NCrypto Encryption & Decryption - 05-02-2005 , 08:14 PM






I managed to do this with Michel Gallants articles. But I feel he is
working at a much deeper level than most of us newbies can comprehend.
So, I will write an article that will "DUMB DOWN" the following and
show you exactly how to do:-

-RSA Encryption/Decryption
-Digital Certificate (.cer) public key parsing to get RSAParameters
-PKCS#12 (.pfx) private key parsing to get RSAParameters
-Symmetric Encryption/Decryption

Give me a few days for this. I have finals and school projects at the
moment so need to take care of those first. :-)


Reply With Quote
Reply




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.