【H5】两种加密解码方法:
encodeURI(); //加密 decodeURI(); //解密
加密成base64编码格式 btoa() 加密 atob() 解密
实现代码如下:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document
</title>
</head>
<body>
<script>
const str = "帅德布耀布耀滴小雯老公";
let strm = encodeURI( str )
console.log( encodeURI( str ) )
const str1 = '帅德布耀布耀滴小雯老公'
console.log( decodeURI( str1 ) )
const str2 = encodeURI("帅德布耀布耀滴小雯老公")
console.log( str2 )
const str3 = btoa( str2 );
console.log( str3 )
const str4 = atob( str3 );
console.log( str4 )
const str5 = decodeURI( str4 );
console.log( str5 )
</script>
</body>
</html>
运行效果如下: