如何在Windows Phone上使用c++/cx获得加密安全随机性
How to get cryptographically secure randomness with c++/cx on Windows Phone?
显然在.NET
中有可用的System.Security.Cryptography.RNGCryptoServiceProvider
类。但这是我的理解(我是windows phone 8开发的新手),我无法从c++/cx访问该函数…或者我可以吗?
我没能在我可能使用的Windows Phone API中找到任何其他函数/类。我错过了什么?
我发现我实际上可以使用WinRT Windows.Security.Cryptography
API从c++/cx。
解决方法是简单地
auto iBuffer = Windows::Security::Cryptography::CryptographicBuffer::GenerateRandom(rand_len);
从iBuffer中获取数据,我使用了这个答案:
auto reader = Windows::Storage::Streams::DataReader::FromBuffer(iBuffer);
std::vector<unsigned char> data(reader->UnconsumedBufferLength);
if (!data.empty())
reader->ReadBytes(
::Platform::ArrayReference<unsigned char>(
&data[0], data.size()
)
);
相关文章:
- AES加密到解密未正确输出
- 加密++验证大文件签名
- 通过 Openssl 命令行加密,通过 c++ 解密
- 如何在加密++中将两个源组合成新的源
- 在TFHE(完全快速同态加密)上执行除法
- 使用不同算法的 PKCS1v15 填充进行加密 ++ 签名
- 加密在 Windows、C++ 和 Java 中传输中的数据
- 将加密消息从 php 发送到 C++ 应用程序,然后使用 CryptoPP 进行解密
- 使用公钥加密消息:BER 解码错误
- OpenSSL API,使用GCM(伽罗瓦计数器模式)进行AES加密
- 邮件加密程序崩溃
- 获取加密的正文响应WinHttp HTTPS
- 我正在尝试为家庭作业加密邮件
- 使用C++挂载功能挂载加密
- POCO C++加密/解密
- 使用 char 数组公钥的 OpenSSL 进行 RSA 加密
- 从加密项目向量中解密任意选择的元素会导致无效的 PKCS #7 块错误
- 尝试从 Visual Studios C++ 中的加密字符串输出解密字符串时出现逻辑错误
- 压缩天然气.AES.错误解密(可能加密)的文件
- 如何在Windows Phone上使用c++/cx获得加密安全随机性