求救:System.NullReferenceException: 未将对象引用设置到对象的实例
请各位高人指点迷津,不胜感谢!
//测试给出的密码是否正确
public bool TestPassword(string pass)
{
byte[] encryptPass=user.Encrypt(pass);
for (int i = 0; i<encryptPass.Length; i++)
{
if (encryptPass[i] != user.password[i])
return false;
}
return true;
}
错误提示行: if (encryptPass[i] != user.password[i])未将对象引用设置到对象的实例
附://使用SHAI算法加密指定的字符串
public byte[] Encrypt(string plainText)
{
UnicodeEncoding encoding = new UnicodeEncoding();
byte[] hashBytes = encoding.GetBytes(plainText);
//计算SHA-1散列值
SHA1 sha1 = new SHA1CryptoServiceProvider();
return sha1.ComputeHash(hashBytes);
}