guacamole 的前台base64加密方式

var s = "otherhostcdefault";
var uint8array = new TextEncoder("utf-8").encode(s);
var getBase64 = function getBase64(bytes) {
var data = "";
// Produce binary string from bytes in buffer
for (var i = 0; i < bytes.byteLength; i++)
data += String.fromCharCode(bytes[i]);
// Convert to base64
return window.btoa(data);

};
alert(getBase64(uint8array))

 

 

 

var uint8array = new TextEncoder("utf-8").encode("¢");
var string = new TextDecoder("utf-8").decode(uint8array);
posted @ 2017-12-02 13:03  花道长  阅读(271)  评论(0编辑  收藏  举报