//PHP base64_encode
function str_encode($str){
return base64_encode(iconv('GB18030',strof-8,stro !');
?>
///////////////////////////////////////// /////////////////////////////////////////////
另附PHP的base64的加解密函數!
{echo base64_encode($str)."
"; //加密
echo base64_decode(ss// ////////////////////////////////////////////////// /////////////////////// UTF-8 UTF-16 convertion
*
* Copyright (C) 1999 Masanao Izumo
* Version: 1.0
* This
* LastModified: Dec 25 1999 can redistribute it and/or modify it.*/
/*
* Interfaces:
* utf8 = utf16to8(utf16);
* utf16 = utf16to8(utf8);
var out, i, len, c;
out = "";
len = str.length;
}
}
}
function utf8to16(str) {
out = "";
len = str.length;
i = 0;
while(i >4)
{
案例0:案例1: 案例2: 案例3: 案例4: 案例5: 案例6: 案例7:
// 0xxxxxxx
break;
個案12: 個案13 :
/ / 110x xxxx 10xx xxxx
char2 = str.charCodeAt(i++);
3F));
休息;
狀況14:
/ / 1110 xxxx 10xx xxxx 10xx xxxx
char2 = str.charCodeAt(i++);
out += String.fromCharCode (((c & 0x0F)
中斷;
}
}
.co.jp>
* 版本:1.0
* 最後修改時間:1999 年12 月25 日
* 該庫是免費的。 您可以重新分發和/或修改它。
/*
* b64 = base64encode(data);
* data = base64decode(b64);
*/
var base64DecodeChars = new Array (
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, - 1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
52, 53 , 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25 , -1, - , -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1);
function base64encode(str) {
var out , i, len; c2, c3;
len = str.length;
i = 0;
out = "";
while(i {
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt((c1 & 0x3) }
c2 = str.charCodeAt ( i++);
if(i == len)
{
out += base64EncodeChars.charAt(((c1 & 0x3) )> 4));
out += base64EncodeChars.charAt((c2 & 0xF) }
c3 = str.charCodeAt( i++ );
out += base64EncodeChars.charAt(c1 >> 2);
out += base64EncodeChars.charAt(((c1 & 0x3) out + = base64EncodeChars.charAt(((c2 & 0xF) > 6));
out += base64EncodeChars.charAt(c3 & 0x3F);
function base64decode(str) {
var c1, c2, c3, c4;
var i, len, out;
len = str.length; while(i /* c1 */
do {
} while(i if(c1 ==- 1 )
月;
/* c2 */
At(i++) & 0xff];
} while(i if(c2 = = -1)
break;
out += String.fromCharCode((c1 > 4)
do {
c3 = 海峽。 (i++) & 0xff;
if(c3 == 61)
} while(i 若(c3 == -1)
中斷;
out += String.fromCharCode(((c2 & 0XF) > 2));
/* c4 */
do {
4 == 61)
返回;
c4 = base64DecodeChars[cb]; = -1);
if(c4 == -1)
break;
}
return out;
}
//輸入base64編碼
函數strdecode(str){
return utf8to16(base64decode(str));
}
document.write(strdecode('5L2g5a