在前端中使用base64加密算法對cookie中的數據進行加密解密操作,具體方法如下:
<!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);
alert("base64 decode:" + str);
</script>
</head>
<body>
</body>
</html>