Reading through this reference article: https://msdn.microsoft.com/en-us/library/xh68ketz(v=vs.110).aspx
Also found the same question asked here: CryptographicException - Unable to update the password
However, there is no answer.
In attempting to use the legacy
example, I am able to create and store protected columns into a sqlite database.
However, when re-calling those same values to unprotect, VS throws an exception.
My Current retrieval:
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();
}
However, this is throwing an exception with this line:
privkey = Convert.ToString(ProtectedData.Unprotect(privkey_enc, null, DataProtectionScope.CurrentUser));
Throwing the following error:
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.
I'm not sure I understand why/what password it's referencing changing. I am simply trying to unprotected an already protect stored value.