在前端中使用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>