欢迎您访问 最编程 本站为您分享编程语言代码,编程技术文章!
您现在的位置是: 首页

初探JS中MD5加密算法的使用

最编程 2024-02-03 09:04:03
...
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
//引入MD5方法的标签
<script src="https://cdn.bootcss.com/blueimp-md5/2.10.0/js/md5.min.js"></script>
</head>
<body>

<form action="#" method="post" name="">
<p>
<span>用户名:</span> <input type="text" id="username">
</p>
<p>
<span>密码:</span> <input type="password" id="password" >
</p>

<!-- 绑定一些事件 onclick被点击-->
<button type="button" onclick="aaa()" >提交</button>
</form>


<script>
function aaa() {
var uname=document.getElementById('username');
var pwd=document.getElementById('password');
console.log(uname.value)
pwd.value=md5(pwd); //运用MD5进行加密,保护用户密码
console.log(pwd.value)
}
</script>
</body>
</html>

推荐阅读