JavaScript的MD5加密
2024-09-06 00:19:00
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>
- <head>
- <script type="text/javascript" src="md5.js"></script>
- <script>
- function md5(){
- var hash=hex_md5(document.getElementById("text").value);
- document.getElementById("result").value=hash;
- }
- function trans(){
- frm.pwd.value =hex_md5(frm.pwd.value);
- document.getElementById("result2").value=frm.pwd.value;
- }
- function submit(){
- //默认的提交处理,自定义的提交前处理方法不要用submit作为函数名
- }
- //onsubmit="pwd.value =hex_md5(pwd.value)"
- </script>
- </head>
- <body>
- http://pajhome.org.uk/crypt/md5/<br>
- MD5加密:<br>
- 转换前:<input type="text" id="text" style="width:300" value="hello world"/><br>
- 转换后:<input type="text" id="result" style="width:300"/><br>
- <input type="button" value="test" onclick="md5()"/>
- <br>
- <form name="frm" >
- name:<input type="text" id="name" /><br>
- password:<input type="password" id="pwd"/><br>
- <input type="button" value="submit" onclick="trans()" /><br>
- 加密后的密码:<input type="text" id="result2" style="width:300"/>
- </form>
- </body>
- </html>
from: http://hongan.iteye.com/blog/287044
最新文章
- iOS集成sharesdk遇到的坑
- Android-Eclipse-INSTALL_FAILED_UPDATE_INCOMPATIBLE错误
- HTML5 Canvas核心技术图形动画与游戏开发(读书笔记)----第一章,基础知识
- gcd 最小公约数
- Echarts-画堆积柱状图,折线图
- JavaScript BOM对象介绍
- POS管理系统之新增设备入库
- lucene索引
- The resource could not be loaded because the App Transport Security policy requires the use of a secure connection
- banner轮播图js
- Flume用来收集日志,zeppelin用来展示
- Duanxx的技术问题:word界面显示模糊
- 在Eclipse中运行hadoop程序
- 监听器和web国际化
- LeetCode OJ 82. Remove Duplicates from Sorted List II
- php基础知识掌握——四种界定符
- Android 在通知栏实现计时功能
- MySQL:1366 - Incorrect string value错误解决办法
- 【接口时序】3、UART串口收发的原理与Verilog实现
- SCU 4438:Censor