1. 程式人生 > >じ☆veve深藍的專欄

じ☆veve深藍的專欄

1、base64加密:在頁面中引入base64.js檔案,呼叫方法為:

<!DOCTYPE HTML>
<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);  
        console.log("base64 decode:" + str);  
</script>  
</head>

<body>
</body>
</html>

2、md5加密 :在頁面中引用md5.js檔案,呼叫方法為

<!DOCTYPE HTML>
<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");
    console.log(hash)
</script>  
</head>

<body>
</body>
</html>

3、sha1加密:頁面中引入sha1.js(據說這是最安全的加密),呼叫方法為

<!DOCTYPE HTML>
<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')
    console.log(sha)   
</script>  
</head>

<body>
</body>
</html>