Question:
I'm upgrading from an older version of Chilkat Crypt library for .NET to the 4.5 library (32-bit). The api seems to have significantly changed and can't find an example that loads from the certificate store. My old code looked like this:
Crypt crypt = new Crypt();
crypt.UnlockComponent("whatever");
crypt.SetAlgorithmRSA();
CreateCS ccs = new CreateCS();
CertStore store = ccs.OpenLocalSystemStore();
Cert c = store.FindCertBySubjectCN(subjectCN);
if (c != null)
{
crypt.SetEncryptCertificate(c);
}
else
{
throw new ApplicationException("Cannot find certificate " + subjectCN);
}
byte[] encryptedBytes = crypt.Encrypt(b);
return crypt.EncodeBase64(encryptedBytes);
The best example I could find was here: https://www.example-code.com/csharp/rsa_encryptCreditCard.asp but it doesn't map easily to what I have.
I think I figured out how to 64 bit encode, but how do I set the algorithm to RSA and set the certificate?
Thanks.