数据加密和解密

None.gif
None.gif            
if ( ! File.Exists( " c:\\user.ini " ))
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif {
InBlock.gif                StreamWriter sw 
= new StreamWriter("c:\\user.ini");
InBlock.gif                
string strName = tbName.Text;
InBlock.gif                
string strPass = tbPass.Text;
InBlock.gif                
string strEncryPass = System.Web.Security.FormsAuthentication.
InBlock.gif                    HashPasswordForStoringInConfigFile(strPass,
"md5");
InBlock.gif                sw.WriteLine(strName);
InBlock.gif                sw.WriteLine(strEncryPass);
InBlock.gif                sw.Close();
InBlock.gif                
// 数据加密函数System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(strPass,"md5")
ExpandedBlockEnd.gif
            }

None.gif            
else
ExpandedBlockStart.gifContractedBlock.gif            
dot.gif {
InBlock.gif                
//从user.ini中读出保存的用户名称和密码,进行比较
InBlock.gif
                StreamReader sr = new StreamReader("c:\\user.ini");
InBlock.gif                
string strSaveName = sr.ReadLine();
InBlock.gif                
string strSavePass = sr.ReadLine();
InBlock.gif                sr.Close();
InBlock.gif                
string strInputPass = System.Web.Security.FormsAuthentication
InBlock.gif                    .HashPasswordForStoringInConfigFile(tbPass.Text,
"md5");
InBlock.gif                
if(strSaveName!=tbName.Text||strSavePass!=strInputPass)
ExpandedSubBlockStart.gifContractedSubBlock.gif                
dot.gif{
InBlock.gif                    Response.Write(
"用户名称或密码错误!");
InBlock.gif                    mainPanel.Visible 
= false;
ExpandedSubBlockEnd.gif                }

InBlock.gif                
else
InBlock.gif                    Response.Write(
"<script language = javascript>alert('成功登录!')</script>");
ExpandedBlockEnd.gif            }
数据加密
    方法一:
  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值