宝哥软件园

php使用地穴()函数进行加密

编辑:宝哥软件园 来源:互联网 时间:2021-09-04

一、代码

?php $str='应用地穴()函数进行单向加密!';//声明字符串变量$str echo '加密前$str的值为:'.$ str $ crypt ostr=crypt($ str);//对变量$str加密回声报加密后$str的值为:'.$ crypt ostr/输出加密后的变量?二、运行结果

参数不带盐,每次加密得出的密文都不一样。加密前$str的值为:应用地穴()函数进行单向加密!加密后$str的值为$ 1 $ re4。gg4。$ d . yd 00xx 0 fffifp6krkgn 0

三、代码

!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN ' ' http://www .w3。L1-过渡时期。DTD ' html xmlns=' http://www .w3。org/1999/XHTML ' head meta http-equiv=' Content-Type ' Content=' text/html;字符集=GB 2312/标题使用地窖函数进行数据验证/title style type='text/css '!- body,td,th { font-size : 12px} body { margin-left : 10px;页边距-top : 10px;右边距: 10px边距-底部: 10px} .STYLe 1 { font-size : 14px字体粗细:粗体;}-/style/head body div align=' center '?PHP $ conn=MySQL _ connect(‘localhost’‘root’‘root’)或' die('数据库链接错误. MySQL _ error());mysql_select_db('db_database21 ',$conn)或' die('数据库访问错误. MySQL _ error());MySQL _ query('集名GB 2312 ');/div表格宽度='777 '高度='587 '边框='0 '对齐='中心'单元格填充='0 '单元格间距='0 '背景='images/bg.jpg' tr td宽度='149 '高度=' 200 '/TD TD TD宽度=' 448 '/TD TD TD宽度=' 158 '/TD/tr TD高度=' 187 '/TD TD TD对齐='中心' valign='中间'表单id='form1 '名称='form1 '用户名:/span/TD width=' 100 ' height=' 30 ' align=' left ' valgn=' middle ' scope=' col ' label for=' textfield '/label input name=' username ' type=' text ' id=' username ' size=' 24 '/TD width=' 100 ' align=' center ' valgn=' middle ' scope=' col '/TD/tr TD height=' 30 ' align=' right ' valgn=' middle ' class=' style 1 ' scope=' col '密码:/td td高度=' 30 ' align=' left ' valgn=' middle ' scope=' col '输入名称=' password type=' password ' id=' password ' size=' 25 '/TD TD对齐=' center ' valgn=' middle ' scope=' col '/TD/tr TD高度=' 40 ' col span=' 3 ' align=' center ' valgn=' middle ' scope=' col ' input type=' image ' name=' imageField ' src=' http : images/BGJPG/输入类型='图像'名称=' image field 2 ' src=' http : images/bg1 . JPG。reset();返回false'//td /tr /table /form?PHP if(trim($ _ POST[用户名])!=' '并修剪($ _ POST[密码])!=' '){ $ usr=crypt(trim($ _ POST[用户名]),$ _ POST[用户名]);$ pwd=crypt(trim($ _ POST[密码]),$ _ POST[密码]);$sql='从tb_user中选择*其中用户名=' ' .$usr .和密码=' '。$pwd。$rst=mysql_query($sql,$ conn);$ result=MySQL _ num _ rows($ rst);if($ result 0){ echo ' font color=' red '用户登录成功/font ';}else{ echo 'font color='green '用户登录失败!/font ';} }else{ echo '请认真填写用户名和密码!} ?TD/TD/TD/tr/tr高度=' 200 '/TD/TD/TD/tr/table/body/html四、运行结果

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持我们。

更多资讯
游戏推荐
更多+