JS实现HTTP安全传输密码

  通常在实现网站用户登录时的登录数据传输是以明文形式传到服务器的,这就给了黑客从中截取密码的机会,这里介绍一种避免密码被截取的常用方法。那就是在客户端用JS对密码进行MD5加密。

  1.JS没有内置MD5加密函数,我们需要自己去下载。这里推荐一个成熟的MD5加密函数:

  介绍:http://pajhome.org.uk/crypt/md5/

  下载链接:http://pajhome.org.uk/crypt/md5/md5.js

  2.调用md5.js

  <script src="md5.js" type="text/javascript"><!--mce:0--></script>

  3.加密

  <script type="text/javascript"><!--mce:1--></script>

         具体在表单中的实现可以是这样的:

<form action="b.php" enctype="application/x-www-form-urlencoded">
       <input id="username" name="username" type="text" />
       <input id="pwd" name="pwd" type="password" />
  </form>

  补充:更安全的做法是在服务端生成一个随机字符串A,客户端加密前将要加密的字符串B与A相加再进行加密,在服务端的验证也进行相应进行即可。


( ! ) Warning: Missing argument 1 for cwppos_show_review(), called in /data/www/enjoyphp/wp-content/themes/flat/content-single.php on line 29 and defined in /data/www/enjoyphp/wp-content/plugins/wp-product-review/includes/legacy.php on line 18
Call Stack
#TimeMemoryFunctionLocation
10.0000355192{main}( ).../index.php:0
20.0001355480require( '/data/www/enjoyphp/wp-blog-header.php' ).../index.php:17
30.173110167520require_once( '/data/www/enjoyphp/wp-includes/template-loader.php' ).../wp-blog-header.php:19
40.174410238664include( '/data/www/enjoyphp/wp-content/themes/flat/single.php' ).../template-loader.php:74
50.282010808552get_template_part( ).../single.php:5
60.282010809072locate_template( ).../general-template.php:167
70.282110809168load_template( ).../template.php:643
80.282110809552require( '/data/www/enjoyphp/wp-content/themes/flat/content-single.php' ).../template.php:686
90.288010796424cwppos_show_review( ).../content-single.php:29

发表评论

电子邮件地址不会被公开。 必填项已用*标注