RijndaelManaged Specified键不是此算法的有效大小

时间:2016-02-26 20:56:54

标签: c# sql encryption aes rijndaelmanaged

 using (RijndaelManaged rijAlg = new RijndaelManaged())  
        rijAlg.Key = Key;
        rijAlg.IV = IV;

这给了我一个错误"指定的密钥不是此算法的有效大小。"

获取Key和IV

    string checkPass = "select password from UserName where Username = '" + TBLoginUser.Text + "'";
    SqlCommand pass = new SqlCommand(checkPass, conn);
    string password = pass.ExecuteScalar().ToString();

    string checkKey = "select encKey from UserName where Username = '" + TBLoginUser.Text + "'";
    SqlCommand k = new SqlCommand(checkKey, conn);
    string key = k.ExecuteScalar().ToString();

    string checkIV = "select encIV from UserName where Username = '" + TBLoginUser.Text + "'";
    SqlCommand x = new SqlCommand(checkIV, conn);
    string iv = x.ExecuteScalar().ToString();



    byte[] keyByte = Encoding.ASCII.GetBytes(key);
    byte[] ivByte = Encoding.ASCII.GetBytes(iv);

任何人都可以提供帮助吗?

0 个答案:

没有答案