Archived Forum Post

Index of archived forum posts

Question:

Having problems using a .NET .snk Key File for RSA Encryption in C++

Mar 15 '13 at 09:07

Hello. I am having trouble with using the .snk files with this example code (http://www.example-code.com/vcpp/rsa_snk.asp). I've generated a .snk file called adamKeyPair using the strong name tool. The program is compiling fine, however it does not seem to be reading the snk file and getting the keys. Below is the code fragment I am using to test if it is reading it. The xmlKey is showing blank when the program runs. I have the .snk file in the project folder along with the studio solution. Do I have the file in the wrong place, or is there more I should be doing with the snk file beforehand?

const char * xmlKey; xmlKey = rsa.snkToXml("adamKeyPair.snk"); std::cout << "Adam's Keys: " << xmlKey << std::endl;


Answer

After calling snkToXml, examine the contents of the rsa.lastErrorText() to get information about what happened. This is the standard way of getting information about what transpired within the last method called on a Chilkat object instance.