我使用AES加密了MS Access文件中的每个项目。加密效果很好。问题是我收到了错误:Argument 1: cannot convert from 'object' to 'string'
在这样的行上:security.Decrypt(readPersonalData.GetValue(1), storedAuth.Password, storedAuth.UserName)
我该如何避免这种情况?
if (readPersonalData.HasRows)
{
while (readPersonalData.Read())
{
// Count all entries read from the reader.
countEntries++;
txtDisplay.Text += "=== Entry ID: " + readPersonalData.GetValue(0) + " ===" + Environment.NewLine;
txtDisplay.Text += "Type: " + security.Decrypt(readPersonalData.GetValue(1), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
if (!readPersonalData.IsDBNull(2)) txtDisplay.Text += "URL: " + security.Decrypt(readPersonalData.GetValue(2), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
if (!readPersonalData.IsDBNull(3)) txtDisplay.Text += "Software Name: " + security.Decrypt(readPersonalData.GetValue(3), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
if (!readPersonalData.IsDBNull(4)) txtDisplay.Text += "Serial Code: " + security.Decrypt(readPersonalData.GetValue(4), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
if (!readPersonalData.IsDBNull(5)) txtDisplay.Text += "User Name: " + security.Decrypt(readPersonalData.GetValue(5), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
if (!readPersonalData.IsDBNull(6)) txtDisplay.Text += "Password: " + security.Decrypt(readPersonalData.GetValue(6), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
txtDisplay.Text += Environment.NewLine;
}
}
答案 0 :(得分:2)
你可以试试 -
txtDisplay.Text += "Type: " + security.Decrypt(readPersonalData.GetString(1), storedAuth.Password, storedAuth.UserName) + Environment.NewLine;
哪个应该返回一个可以传递给security.Decrypt
函数的字符串。