怎么使用16进制编码的RSA公钥进行RSA加密

如何使用16进制编码的RSA公钥进行RSA加密?
java加密方法如下:

String modeHex = "D548C6267CC503F1E926776A97F8644CAA67167E8FA5D74FD1F4E0BCB3608BD1583E41B102B5B4617E53B90A0C67EA652F8D96B40CFDDA6BC1501432ADCE15E4B5B916568893C94FF3CAC5ED5942FC604BAD1B12DF7683B25C6702BD8CF1BE2F5A4FFC97C82E42FD91E49A6EFF379F5F022F36E5395D64FC9430EEFCAC55F0A5";
String exponentHex = "10001";
 
KeyFactory factory = KeyFactory.getInstance("RSA");
 
BigInteger n = new BigInteger(modeHex, 16);
BigInteger e = new BigInteger(exponentHex, 16);
RSAPublicKeySpec spec = new RSAPublicKeySpec(n, e);
 
RSAPublicKey pub = (RSAPublicKey) factory.generatePublic(spec);
Cipher enc = Cipher.getInstance("RSA");
enc.init(Cipher.ENCRYPT_MODE, pub);
 
byte[] encryptedContentKey = enc.doFinal(messageg.getBytes("GB2312"));
 
String result = new String(Hex.encodeHex(encryptedContentKey));




 在此请教各位高手,用c++ CryptAPI怎么实现以上java代码一样的功能,或者用openssl、crypt++等加密库

 问题解决马上结贴(200分),谢谢
------解决方案--------------------
仅供参考
#pragma comment(lib, "crypt32.lib")
#pragma comment(lib, "advapi32.lib")
#define _WIN32_WINNT 0x0400
#include <stdio.h>
#include <windows.h>
#include <wincrypt.h>
#define MY_ENCODING_TYPE  (PKCS_7_ASN_ENCODING 
------解决方案--------------------
 X509_ASN_ENCODING)
#define KEYLENGTH  0x00800000
void HandleError(char *s);
//--------------------------------------------------------------------
//  These additional #define statements are required.
#define ENCRYPT_ALGORITHM CALG_RC4
#define ENCRYPT_BLOCK_SIZE 8
//   Declare the function EncryptFile. The function definition
//   follows main.
BOOL EncryptFile(
    PCHAR szSource,
    PCHAR szDestination,
    PCHAR szPassword);
//--------------------------------------------------------------------
//   Begin main.
void main(void) {
    CHAR szSource[100];
    CHAR szDestination[100];
    CHAR szPassword[100];
    printf("Encrypt a file. \n\n");
    printf("Enter the name of the file to be encrypted: ");
    scanf("%s",szSource);
    printf("Enter the name of the output file: ");
    scanf("%s",szDestination);
    printf("Enter the password:");
    scanf("%s",szPassword);
    //--------------------------------------------------------------------
    // Call EncryptFile to do the actual encryption.
    if(EncryptFile(szSource, szDestination, szPassword)) {
        printf("Encryption of the file %s was a success. \n", szSource);
        printf("The encrypted data is in file %s.\n",szDestination);
    } else {
        HandleError("Error encrypting file!");
    }
} // End of main
//--------------------------------------------------------------------
//   Code for the function EncryptFile called by main.
static BOOL EncryptFile(
    PCHAR szSource,
    PCHAR szDestination,
    PCHAR szPassword)
//--------------------------------------------------------------------
//   Parameters passed are:
//     szSource, the name of the input, a plaintext file.
//     szDestination, the name of the output, an encrypted file to be
//         created.
//     szPassword, the password.
{
    //--------------------------------------------------------------------
    //   Declare and initialize local variables.
    FILE *hSource;
    FILE *hDestination;
    HCRYPTPROV hCryptProv;
    HCRYPTKEY hKey;
    HCRYPTHASH hHash;
    PBYTE pbBuffer;
    DWORD dwBlockLen;
    DWORD dwBufferLen;
    DWORD dwCount;
    //--------------------------------------------------------------------
    // Open source file.
    if(hSource = fopen(szSource,"rb")) {