locked
Sign string with PrivateKey using RSA 2048 RRS feed

  • Question

  • Hello there.

    I need to sign a data with a RSA signature that I have already generated on my local machine.

    I generated the private key and from this generated a public key that I provided the receiving end with.

    NOW I need to make sure that this private key is the key that I sign all my data with before sending it through the service.

    Can I specify the key I should sign the data with in the "RSACryptoServiceProvider" somehow before I use the "SignData" function?

    Thursday, July 8, 2010 11:51 AM

Answers

  • If you want to put it into the RSACryptoServiceProvider then you need to do the following:

    RSACryptoServiceProvider rsa = new RSACryptoServiceProvider();
    
    RSAParameters rsaparams = new RSAParameters() { //fill out you public/private key information here }
    
    rsa.ImportParameters( rsaparams );
    
    rsa.SignData( ... );
    
    

    Once you have the RSACryptoServiceProvider ready the first time you can export your settings via the rsa.ToXMLString() method. When you want to use those same settings again, you use the rsa.ToXMLString() method to read it back in.

    • Marked as answer by Harry Zhu Wednesday, July 14, 2010 8:10 AM
    Thursday, July 8, 2010 5:25 PM