html5对密码加密


今天找了几个关于对html5的密码加密的方法,仅供参考

1、base64加密:在页面中引入base64.js文件,调用方法为:

<html>  
<head>  
<meta charset="utf-8">  
<title>base64加密</title>  
<script type="text/javascript" src="base64.js"></script>  
<script type="text/javascript">    
        var b = new Base64();    
        var str = b.encode("admin:admin");    
        alert("base64 encode:" + str);    
     //解密  
        str = b.decode(str);    
        alert("base64 decode:" + str);    
</script>    
</head>  
  
<body>  
</body>  
</html>  

base64下载:http://files.cnblogs.com/mofish/base64.js

2、md5加密:在页面中引用md5.js文件,调用方法为:

<html>  
<head>  
<meta charset="utf-8">  
<title>md5加密</title>  
<script type="text/ecmascript" src="md5.js"></script>  
<script type="text/javascript">    
  var hash = hex_md5("123dafd");  
    alert(hash)  
</script>    
</head>  
  
<body>  
</body>  
</html> 

md5下载:md5.js:http://files.cnblogs.com/mofish/md5.js

3、sha1加密,据说这是最安全的加密:页面中引入sha1.js,调用方法为

<html>  
<head>  
<meta charset="utf-8">  
<title>sha1加密</title>  
<script type="text/ecmascript" src="sha1.js"></script>  
<script type="text/javascript">  
  var sha = hex_sha1('mima123465')  
    alert(sha)     
</script>    
</head>  
  
<body>  
</body>  
</html>

 

sha1下载:http://files.cnblogs.com/mofish/sha1.js


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM