1

I use some win32 api create a pravite/public key pair and write them to files. that i do:

    CryptGenKey(hProv, CALG_RSA_KEYX, KEYLENGTH | CRYPT_EXPORTABLE | CRYPT_NO_SALT, &hSessionKey);
    // export private key buffer and write it to file
    CryptExportKey(hSessionKey, NULL, PRIVATEKEYBLOB, 0, key_buf, &keySize ); //export private 
key
    //export public key buffer and write it to file 
    CryptExportKey(hSessionKey, NULL, PRIVATEKEYBLOB, 0, key_buf, &keySize );

That are no problem, and my question is how can i import the key from private key file, and encrypt data use that key; And import public key from public file to decrypt that encrypted data;

how can do ? thanks...

bruceLi
  • 11
  • 1
  • 2

1 Answers1

0

http://blogs.msdn.com/b/alejacma/archive/2008/01/28/how-to-generate-key-pairs-encrypt-and-decrypt-data-with-cryptoapi.aspx

hope this article helps, it clearly shows how to encrypt and decrypt data with CryptoAPI.

Balu
  • 2,247
  • 1
  • 18
  • 23