阅读此参考文章:https://msdn.microsoft.com/en-us/library/xh68ketz(v=vs.110).aspx
此处也发现了同样的问题:CryptographicException - Unable to update the password
然而,没有答案。
在尝试使用legacy
示例时,我能够创建受保护的列并将其存储到sqlite数据库中。
但是,当重新调用那些相同的值进行unprotect时,VS会抛出异常。
我当前的检索:
string sql = "select privkey from pp_users where pubkey=[REDACTED]";
SQLiteCommand user_privkey = new SQLiteCommand(sql, m_dbConnection);
SQLiteDataReader reader = user_privkey.ExecuteReader();
while (reader.Read())
{
string privkey;
Byte[] privkey_enc = ObjectToByteArray(reader["privkey"]);
privkey = Convert.ToString(ProtectedData.Unprotect(privkey_enc, null, DataProtectionScope.CurrentUser));
Console.WriteLine("Your private key is: " + privkey);
}
Console.ReadLine();
private byte[] ObjectToByteArray(Object obj)
{
if (obj == null)
return null;
BinaryFormatter bf = new BinaryFormatter();
MemoryStream ms = new MemoryStream();
bf.Serialize(ms, obj);
return ms.ToArray();
}
然而,这是在这一行引发异常:
privkey = Convert.ToString(ProtectedData.Unprotect(privkey_enc, null, DataProtectionScope.CurrentUser));
抛出以下错误:
An unhandled exception of type 'System.Security.Cryptography.CryptographicException' occurred in System.Security.dll
Additional information: Unable to update the password. The value provided for the new password does not meet the length, complexity, or history requirements of the domain.
我不确定我理解为什么/它引用了哪些密码更改。我只是试图不受保护已经保护存储的价值。