I have the latest one month trial chilkat dll version file for encryption. I want to encrypt the message in RSA 2048 where public/private(generated in some other tool) keys are given to me and kept in a file like 'a.txt' or 'a' or 'a.key' (This file is not snk file), this file consist the key in the following way:
I took this key and made it 'a.pem' file manually and set the public key as per pem file format. I used this
file pem file and successfully encrypted the message using RSA. I do not want to this manual conversion. I
just want to take the public key from a file or a field from database and use it straight a way without any
Please let me know how can I achieve this.
I commented my older code and implement the code as per your suggestions. Following is my code:
But the LoadOpenSslPem function failed, please correct me if I did any mistake.
Examine the contents of the LastErrorText property for the object whose method call failed. (And make sure to check the return value of each method call for success/failure. There is no point in continuing onward if a method call failed. For example, there's no point in trying to encrypt if the call to pubKey2.LoadOpenSslPem failed.)
answered Dec 11 '14 at 07:47
Load the PEM string into a Chilkat.PublicKey object (or CkPublicKey depending on the programming language), by calling LoadOpenSslPem (see http://www.chilkatsoft.com/refdoc/csPublicKeyRef.html )
Then make the PublicKey object available to the Rsa object via the ImportPublicKeyObj (see http://www.chilkatsoft.com/refdoc/csRsaRef.html)
I used the following the following line: success = pubKey2.LoadRsaDer(crypt.Decode(pub, "base64")) I have done the encryption part.
answered Dec 12 '14 at 00:37