I want to implement a dutch payment system (iDeal Professional - Rabobank) in my ASP.NET 4.0 website. For communication I have to send an XML message with an encrypted string in it.
First I had to create a private key, using the following command (OpenSSL):
openssl genrsa -des3 –out
openssl req -x509 -new -key
1. Create an SHA1 digest message based on a specific string (http://www.itl.nist.gov/fipspubs/fip180-1.htm)
2. Encrypt the digest using the private key and RSA (http://www.rsasecurity.com/rsalabs/node.asp?id=2146 / http://www.rsasecurity.com/rsalabs/node.asp?id=2124)
3. Base64 encode the encrypted message
Step 1 and 3 are no problem, bu does anybody know how to perform step 2?
Thanks in advance for your answer,
Dennieku

Sahil Jani196 reputationPosted Apr 20, 2011, 8:47 PM EDT
Hi,
Here i have written some code to encrypt the mesage using RSA. And normally in RSA message encryption is done using Private key it self.
class Program
{
static void Main(string[] args)
{
RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
StreamReader sr = File.OpenText("myKey.xml");
string rsaXml = sr.ReadToEnd();
sr.Close();
rsa.FromXmlString(rsaXml);
string messageToJane = "this is a test";
byte[] encrypted = rsa.Encrypt(System.Text.ASCIIEncoding.ASCII.GetBytes(messageToJane), false);
FileStream fs = new FileStream("Message.dat", FileMode.Create);
fs.Write(encrypted, 0, encrypted.Length);
fs.Close();
}
}
for writting tis code you have to import some file here as under ::
using System;
using System.IO;
using System.Security;
using System.Security.Cryptography;
using System.Collections.Generic;
using System.Text;
dennieku32 reputationPosted Apr 22, 2011, 1:34 AM EDT
Tanks four your reply. I already tried some code like this, but the problem is that my private key file is not an XML file, so the code crashes at the line FromXmlString. The content of the file looks like:
-----BEGIN RSA PRIVATE KEY-----
Proc-Type: 4,ENCRYPTED
DEK-Info: DES-EDE3-CBC,1595C9C7A54AC3E8
nvd6z9g5r4d72jWDuQoeye/9vRVf3aIrP5x/P92D7yLuBPdA90uUh9jd4DiwLuDm
fU2xIAWIp....
Do you know how I can use a file like this?
Thanks,
Dennieku
Mike Fif15 reputationPosted Oct 13, 2011, 10:13 AM EDT
Did you figure out how to solve that problem? I kind of have the same issue atthe moment. Your reply would be much appreciated.
Kind regards
mike
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 13, 2011, 10:43 AM EDT
System.Diagnostics.Process pProcess = new System.Diagnostics.Process();
pProcess.StartInfo.FileName = "YourOpenSSLCommand";
pProcess.StartInfo.Arguments = "anyargumentstoopenssl";
pProcess.StartInfo.UseShellExecute = false;
pProcess.StartInfo.RedirectStandardOutput = true;
pProcess.StartInfo.WorkingDirectory = "workingdirectory";
pProcess.Start();
string strOutput = pProcess.StandardOutput.ReadToEnd();
pProcess.WaitForExit();
Please do not forget to mark "Accepted Answer"
dennieku32 reputationPosted Oct 13, 2011, 10:51 AM EDT
I bought the Chilkat RSA component, which solved my problem. Check http://www.chilkatsoft.com/rsa-dotnet.asp
Javeed M ShaikhRank #839 · 2.7K reputationPosted Oct 13, 2011, 11:25 AM EDT
Mike Fif15 reputationPosted Oct 14, 2011, 9:16 AM EDT
Thanks for your respons.
Cheers
MikeFIF