01.
private
bool
Login(
string
_UserName,
string
_Password)
02.
{
03.
byte
[] CurrentIV =
new
byte
[] { 51, 52, 53, 54, 55, 56, 57, 58 };
04.
byte
[] CurrentKey = { };
05.
if
06.
{
07.
int
i;
08.
string
AddString = _UserName.Substring(0, 1);
09.
int
TotalLoop = 8 - _UserName.Length;
10.
string
tmpKey = _UserName;
11.
for
(i = 1; i <= TotalLoop; i++)
12.
{
13.
tmpKey = tmpKey + AddString;
14.
}
15.
CurrentKey = Encoding.ASCII.GetBytes(tmpKey);
16.
}
17.
desCrypt =
new
DESCryptoServiceProvider();
18.
desCrypt.IV = CurrentIV;
19.
desCrypt.Key = CurrentKey;
20.
21.
ms =
new
MemoryStream();
22.
ms.Position = 0;
23.
cs =
new
CryptoStream(ms, desCrypt.CreateEncryptor());
24.
byte
[] arrByte = Encoding.ASCII.GetBytes(CurrentKey);
25.
cs.Write(arrByte, 0, arrByte.Length);
26.
cs.FlushFinalBlock();
27.
cs.Close();
28.
PwdWithEncrypt = Convert.ToBase64String(ms.ToArray());
29.
30.
var un = from u
in
db.UserNames
31.
where (u.UserName1 == _UserName && u.Password == PwdWithEncrypt)
32.
&& u.IsNormal ==
"1"
select u;
33.
if
(un.Count() > 0)
34.
{
35.
return
true
;
36.
}
37.
else
38.
{
39.
return
false
;
40.
}
41.
}