帮忙看看 加密不对?
密文不能用string 来保存,必须用char[]来保存
string 保存---之前用string来保存,同事说不对
//public string EnPasswd(string passwd)
////参数1:In明文;参数2:Out密文
//{
// char ch;
// char[] w0 = new char[8 + 1];
// char[] w1 = new char[8 + 1];
// int i, s;
// for (i = 0; i < 8; i++)
// {
// w0[i] = '\0';
// w1[i] = '\0';
// }
// for (i = 0; i < passwd.Length; i++)
// {
// w0[i] += Convert.ToChar(passwd.Substring(i, 1));
// }
// for (i = 0, ch = '\0'; i < 8; i++)
// {
// ch += w0[i];
// ch = Convert.ToChar(ch ^ 0xda);
// w0[i] = ch;
// }
// for (i = 0; i < 8; i++)
// {
// ch = w0[i];
// for (s = 0; s < 8; s++)
// {
// w1[(i + s) % 8] |= Convert.ToChar(((Convert.ToInt32(ch) & 1) << i));
// ch >>= 1;
// }
// }
// StringBuilder st = new StringBuilder();
// st = st.Append(w1);
// string res = st.ToString();
// return res;
//}
char[] 保存:
换成char[]来保存与下载的也不相符
//public char[]EnPasswd(string passwd)
////参数1:In明文;参数2:Out密文
//{
// char ch;
// char[] w0 = new char[8 + 1];
// char[] w1 = new char[8 + 1];
// int i, s;
// for (i = 0; i < 8; i++)
// {
// w0[i] = '\0';
// w1[i] = '\0';
// }
// for (i = 0; i < passwd.Length; i++)
// {
// w0[i] += Convert.ToChar(passwd.Substring(i, 1));
// }
// for (i = 0, ch = '\0'; i < 8; i++)
// {
// ch += w0[i];
// ch = Convert.ToChar(ch ^ 0xda);
// w0[i] = ch;
// }
// for (i = 0; i < 8; i++)
// {
// ch = w0[i];
// for (s = 0; s < 8; s++)
// {
// w1[(i + s) % 8] |= Convert.ToChar(((Convert.ToInt32(ch) & 1) << i));
// ch >>= 1;
// }
// }
// return w1;
//}