Signing Data using RSA
-
Hello, I'm having difficulty signing a string using the RSA cryptography algorithm. I've search here in this forum for sample code, but I guess, signing is not that popular. Anyway, any help would be greatly appreciated. here is my code.
public static string SignMyData(string data2Sign)
{
AssignPr(); //assigning the parameter, container, etcbyte[] byte2Sign = System.Text.Encoding.UTF8.GetBytes(data2Sign);
StreamReader reader = new StreamReader(@"C:\MyPrivateKey.xml");
string pubPriKeyXML = reader.ReadToEnd();
rsa.FromXmlString(pubPriKeyXML); //(I'm getting error "Invalid syntax on line 1".)
reader.Close();byte[] byteSig = rsa.SignData(byte2Sign, "SHA1");
return System.Text.Encoding.UTF8.GetString(ByteSig);
}If anyone knows of a simple tutorial or can guide me through this, that would be great Thanks JC
-
Hello, I'm having difficulty signing a string using the RSA cryptography algorithm. I've search here in this forum for sample code, but I guess, signing is not that popular. Anyway, any help would be greatly appreciated. here is my code.
public static string SignMyData(string data2Sign)
{
AssignPr(); //assigning the parameter, container, etcbyte[] byte2Sign = System.Text.Encoding.UTF8.GetBytes(data2Sign);
StreamReader reader = new StreamReader(@"C:\MyPrivateKey.xml");
string pubPriKeyXML = reader.ReadToEnd();
rsa.FromXmlString(pubPriKeyXML); //(I'm getting error "Invalid syntax on line 1".)
reader.Close();byte[] byteSig = rsa.SignData(byte2Sign, "SHA1");
return System.Text.Encoding.UTF8.GetString(ByteSig);
}If anyone knows of a simple tutorial or can guide me through this, that would be great Thanks JC
nyjcr wrote:
rsa.FromXmlString(pubPriKeyXML);
'rsa' seems to be a non-static member variable. You cannot use non-static member variables in static methods. Try changing your method to a non-static one.
-
Hello, I'm having difficulty signing a string using the RSA cryptography algorithm. I've search here in this forum for sample code, but I guess, signing is not that popular. Anyway, any help would be greatly appreciated. here is my code.
public static string SignMyData(string data2Sign)
{
AssignPr(); //assigning the parameter, container, etcbyte[] byte2Sign = System.Text.Encoding.UTF8.GetBytes(data2Sign);
StreamReader reader = new StreamReader(@"C:\MyPrivateKey.xml");
string pubPriKeyXML = reader.ReadToEnd();
rsa.FromXmlString(pubPriKeyXML); //(I'm getting error "Invalid syntax on line 1".)
reader.Close();byte[] byteSig = rsa.SignData(byte2Sign, "SHA1");
return System.Text.Encoding.UTF8.GetString(ByteSig);
}If anyone knows of a simple tutorial or can guide me through this, that would be great Thanks JC
nyjcr wrote:
If anyone knows of a simple tutorial or can guide me through this, that would be great
http://blogs.msdn.com/nicold/archive/2007/09/03/how-to-digitally-sign-a-string.aspx[^]