如何使用Crypto++并为RSA返回可打印的字节/字符数组
How to use Crypto++ and return printable byte/char array for RSA?
我使用以下函数使用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
主页面底部第二行还列出了各种其他编码器。Base64Encoder
最有意义。
当然,在解密之前,您需要再次解码。
相关文章:
- 如何使用Crypto++并为RSA返回可打印的字节/字符数组
- 多字节字符'377777'如何工作?
- 文件名如何在"char"和2字节字符之间工作
- 在 linux/mac 中获取多字节字符的"char"
- 如何编写完全可移植的 4 字节字符常量的编译时初始化
- 操作多字节字符的字符串
- Visual Studio 多字节字符到单个字节
- 以 C++ 为单位递增 16 字节字符数组
- setw() 在包含 UTF-8 多字节字符/码位的字符串上输入错误的输出
- C++子字符串多字节字符
- Windows 中的 4 字节字符字符串
- 创建未知长度的字节/字符数组
- 如何提取tar.gz,包括多字节字符和windows上禁止的字符
- Unicode字符或多字节字符:哪种类型更有效?为什么
- 为具有1字节和2字节字符的字符集实现退格
- c++如何获取下一个多字节字符
- 通过boost::asio传输混合unicode和单字节字符的最佳方式
- 如何在 2 字节字符中存储 1 个数字
- C++返回字符串中最常见字符的函数中的错误.多字节字符
- 在MBCS操作系统上运行单字节字符应用程序的风险