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);

使用示例:

  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. </head>
  19. <body>
  20. http://pajhome.org.uk/crypt/md5/<br>
  21. MD5加密:<br>
  22. 转换前:<input type="text" id="text" style="width:300" value="hello world"/><br>
  23. 转换后:<input type="text" id="result" style="width:300"/><br>
  24. <input type="button" value="test" onclick="md5()"/>
  25. <br>
  26. <form name="frm" >
  27. name:<input type="text" id="name" /><br>
  28. password:<input type="password" id="pwd"/><br>
  29. <input type="button" value="submit" onclick="trans()" /><br>
  30. 加密后的密码:<input type="text" id="result2" style="width:300"/>
  31. </form>
  32. </body>
  33. </html>

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

最新文章

  1. iOS集成sharesdk遇到的坑
  2. Android-Eclipse-INSTALL_FAILED_UPDATE_INCOMPATIBLE错误
  3. HTML5 Canvas核心技术图形动画与游戏开发(读书笔记)----第一章,基础知识
  4. gcd 最小公约数
  5. Echarts-画堆积柱状图,折线图
  6. JavaScript BOM对象介绍
  7. POS管理系统之新增设备入库
  8. lucene索引
  9. The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
  10. banner轮播图js
  11. Flume用来收集日志,zeppelin用来展示
  12. Duanxx的技术问题:word界面显示模糊
  13. 在Eclipse中运行hadoop程序
  14. 监听器和web国际化
  15. LeetCode OJ 82. Remove Duplicates from Sorted List II
  16. php基础知识掌握——四种界定符
  17. Android 在通知栏实现计时功能
  18. MySQL:1366 - Incorrect string value错误解决办法
  19. 【接口时序】3、UART串口收发的原理与Verilog实现
  20. SCU 4438:Censor

热门文章

  1. Matplotlib系列(四)--plt.bar与plt.barh条形图
  2. python比C程序相比非常慢
  3. Synchronized 详解
  4. Spring学习(五)--构建Spring Web应用程序
  5. activity知识点
  6. KMP字符串匹配学习
  7. ZOJ 2706 Thermal Death of the Universe
  8. POJ 1438 One-way Traffic (混合图+边双连通)
  9. CF208E Blood Cousins
  10. git 命令图解