记录之...~~~
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _5_09 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s1 = "We are happy!";
Response.Write("字符串"+s1+"经过sha1加密后为:
");
string s2 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(s1, "sha1");
Response.Write(s2);
Response.Write("
");
string s3 = "goodluck";
Response.Write("字符串"+s3+"经过md5加密后为:
");
string s4 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(s1, "md5");
Response.Write(s4);
Response.Write("
");
}
}
结果为:
字符串We are happy!经过sha1加密后为:
CBAFFA21FEAE5252B4E9041581D3080B7D4AFAF5
字符串goodluck经过md5加密后为:
D6C4AD84708D89951BDD8E8C609C0F69
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class _5_09 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string s1 = "We are happy!";
Response.Write("字符串"+s1+"经过sha1加密后为:
");
string s2 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(s1, "sha1");
Response.Write(s2);
Response.Write("
");
string s3 = "goodluck";
Response.Write("字符串"+s3+"经过md5加密后为:
");
string s4 = System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(s1, "md5");
Response.Write(s4);
Response.Write("
");
}
}
结果为:
字符串We are happy!经过sha1加密后为:
CBAFFA21FEAE5252B4E9041581D3080B7D4AFAF5
字符串goodluck经过md5加密后为:
D6C4AD84708D89951BDD8E8C609C0F69
记录一下...~
mysql的两个函数AES_ENCRYPT() 和 AES_DECRYPT(),这两个函数有两个参数,前一个是要加密或解密的字串,后一个是一个自己指定的字串salt,它有助于随机化过程,但必须注意,后一个参数salt在加密和解密时都要相同。如:
用户注册:加密 Insert into tb(user,pass) values ('asd',AES_ENCRYPT('mypass','abc2'))
用户登入:解密 select * from tb where user='asd' and AES_DECRYPT(pass,'abc2') = 'mypass'
可以把salt存入数据库,要使用时,如下:
select @salt := salt From aes_salt;
insert into encode(card_name) values (AES_ENCRYPT(1234560123456,@salt));
php中实现方法也是这样:
$r = mysqli_query($dbc, 'SELECT @salt:=salt From aes_salt);
if(mysqli_num_rows($r)>0){
$r = mysqli_query($dbc,'Select id, AES_DECRYPT(card_name,@salt) AS cc From encode');
$row = mysqli_fetch_array($r,MYSQLI_ASSOC);
.... // Do something
}else{
.... // Do other
}
记住:不要在一条SQL语句内建立并使用用户定义的变量。
mysql的两个函数AES_ENCRYPT() 和 AES_DECRYPT(),这两个函数有两个参数,前一个是要加密或解密的字串,后一个是一个自己指定的字串salt,它有助于随机化过程,但必须注意,后一个参数salt在加密和解密时都要相同。如:
用户注册:加密 Insert into tb(user,pass) values ('asd',AES_ENCRYPT('mypass','abc2'))
用户登入:解密 select * from tb where user='asd' and AES_DECRYPT(pass,'abc2') = 'mypass'
可以把salt存入数据库,要使用时,如下:
select @salt := salt From aes_salt;
insert into encode(card_name) values (AES_ENCRYPT(1234560123456,@salt));
php中实现方法也是这样:
$r = mysqli_query($dbc, 'SELECT @salt:=salt From aes_salt);
if(mysqli_num_rows($r)>0){
$r = mysqli_query($dbc,'Select id, AES_DECRYPT(card_name,@salt) AS cc From encode');
$row = mysqli_fetch_array($r,MYSQLI_ASSOC);
.... // Do something
}else{
.... // Do other
}
记住:不要在一条SQL语句内建立并使用用户定义的变量。
1.直勾勾地盯住正前方的,少于1个月;
2.还经常性地看仪表盘和挡位的,1-3个月;
3.拐弯并线时能够看后视镜3-6个月;
4.会车时主动看清对面来车的号牌的,6-9个月;
5.时不时地跟身边的MM进行视线交流的,9-12个月;
6.能够对行车电脑一目了然,12-18个月;
7.乐于欣赏120度视线内的路边景色,18-24个月;
8.能够根据前方100米以内的路况采取最佳措施,2-3年;
9.变换车道时习惯性地看后视镜,3-4年;
10.能够对周围的车发表评论的,4-5年;
11.能够对后车内MM的相貌做出判断的,5-6年;
12.能够只看后视镜倒车的,6-7年;
13.能够一边开车一边发短信的,7-8年;
14.只看新近设立的交通指示的,8-9年;
15.不知道看什么或者别人不知道他在看什么的,10年以上!
2.还经常性地看仪表盘和挡位的,1-3个月;
3.拐弯并线时能够看后视镜3-6个月;
4.会车时主动看清对面来车的号牌的,6-9个月;
5.时不时地跟身边的MM进行视线交流的,9-12个月;
6.能够对行车电脑一目了然,12-18个月;
7.乐于欣赏120度视线内的路边景色,18-24个月;
8.能够根据前方100米以内的路况采取最佳措施,2-3年;
9.变换车道时习惯性地看后视镜,3-4年;
10.能够对周围的车发表评论的,4-5年;
11.能够对后车内MM的相貌做出判断的,5-6年;
12.能够只看后视镜倒车的,6-7年;
13.能够一边开车一边发短信的,7-8年;
14.只看新近设立的交通指示的,8-9年;
15.不知道看什么或者别人不知道他在看什么的,10年以上!







