首页 > 编程语言 > 详细

JavaScript的MD5加密

时间:2017-12-03 22:38:35      阅读:290      评论:0      收藏:0      [点我收藏+]

1.首先要到http://pajhome.org.uk/crypt/md5/下载js文件。

2.在页面文件中添加:

<script type="text/javascript" src="md5.js"></script>

3.使用函数hex_md5()进行加密,例:

frm.pwd.value =hex_md5(frm.pwd.value);

 

使用示例:

Html代码  技术分享图片
  1. <html>  
  2. <head>  
  3. <script type="text/javascript" src="md5.js"></script>  
  4. <script>  
  5. function md5(){  
  6.   var hash=hex_md5(document.getElementById("text").value);  
  7.   document.getElementById("result").value=hash;  
  8. }  
  9. function trans(){  
  10.   frm.pwd.value =hex_md5(frm.pwd.value);  
  11.   document.getElementById("result2").value=frm.pwd.value;  
  12. }  
  13. function submit(){  
  14.   //默认的提交处理,自定义的提交前处理方法不要用submit作为函数名  
  15. }  
  16. //onsubmit="pwd.value =hex_md5(pwd.value)"  
  17. </script>  
  18.   
  19. </head>  
  20. <body>  
  21. http://pajhome.org.uk/crypt/md5/<br>  
  22. MD5加密:<br>  
  23. 转换前:<input type="text" id="text" style="width:300" value="hello world"/><br>  
  24. 转换后:<input type="text" id="result" style="width:300"/><br>  
  25. <input type="button" value="test" onclick="md5()"/>  
  26. <br>  
  27. <form name="frm" >  
  28. name:<input type="text" id="name" /><br>  
  29. password:<input type="password" id="pwd"/><br>  
  30. <input type="button" value="submit" onclick="trans()" /><br>  
  31. 加密后的密码:<input type="text" id="result2" style="width:300"/>  
  32. </form>  
  33. </body>  
  34. </html>  

 from: http://hongan.iteye.com/blog/287044

JavaScript的MD5加密

原文:http://www.cnblogs.com/ec04/p/7967450.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!