【发布时间】:2019-07-27 16:41:16
【问题描述】:
在不使用 CLR 的情况下,C++ 中 Rfc2898DeriveBytes 的替代方法是什么。下面分享了 C# 示例。
string clearText="text to sign";
string EncryptionKey = "secret";
byte[] clearBytes = Encoding.UTF8.GetBytes(clearText);
using (Aes encryptor = Aes.Create())
{
Rfc2898DeriveBytes pdb = new Rfc2898DeriveBytes(EncryptionKey, new byte[] { 0x48, 0x71, 0x21, 0x6d, 0x21, 0x4c, 0x61, 0x62, 0x72, 0x62, 0x61, 0x62, 0x72 });
encryptor.Key = pdb.GetBytes(32);
encryptor.IV = pdb.GetBytes(16);
using (MemoryStream ms = new MemoryStream())
{
using (CryptoStream cs = new CryptoStream(ms, encryptor.CreateEncryptor(), CryptoStreamMode.Write))
{
cs.Write(clearBytes, 0, clearBytes.Length);
cs.Close();
}
clearText = Convert.ToBase64String(ms.ToArray());
}
}
【问题讨论】:
-
RFC2898 "C++" site:github.com。另请参阅pbkdf2 标签。
-
感谢分享链接...大多数可用的代码实际上并不是 C++ 中的。
-
那么您是说没有足够的替代 C++ 实现可供选择吗?也许社区应该为您找到更多?
标签: c++ cryptography pbkdf2