我正在使用以下函数来加密包含RSA的不可打印字节的字节数组。但是,此函数返回字符串值,并丢失不可打印的字节。
string RSAencrypt(RSA::PublicKey publicKey,string plain) {
string cipher;
try {
AutoSeededRandomPool rng;
RSAES_OAEP_SHA_Encryptor e(publicKey);
StringSource ss1(plain, true,
new PK_EncryptorFilter(rng, e,
new StringSink(cipher)
) // PK_EncryptorFilter
); // StringSource
}
catch (CryptoPP::Exception & e)
{
cerr << "Caught Exception..." << endl;
cerr << e.what() << endl;
}
return cipher;
}
如何返回字节数组?
new HexEncoder(
new StringSink(encoded)
) // HexEncoder
main page的第二行,还有从底部第二行列出的其他各种编码器。 Base64Encoder
最有意义。
当然,您需要再次解码 之前解密。