JS BASE64_ENCODE与BASE64_DECODE的实例代码
12, -1, -1。
50, 24, 61, -1, -1, -1, 8, len, -1。
1, -1, len, 17, c2。
-1, 45, 14, -1。
-1, -1, 11, 27, 25, -1, -1); function base64encode(str) { var out, -1, -1, -1。
-1, 63。
c2, 18, -1, 30, 7, -1, -1, -1, -1, 28。
29, -1, 56, -1。
26, 36。
len; var c1, 0, 51。
-1, -1, -1, 3, -1, -1, -1, 44, -1, -1, 20, 54, 37, 32。
48。
-1, -1, -1, -1, c; out = ; len = str.length; for(i = 0; i len; i++) { c = str.charCodeAt(i); if ((c = 0x0001) (c = 0x007F)) { out += str.charAt(i); } else if (c 0x07FF) { out += String.fromCharCode(0xE0 | ((c 12) 0x0F)); out += String.fromCharCode(0x80 | ((c 6) 0x3F)); out += String.fromCharCode(0x80 | ((c 0) 0x3F)); } else { out += String.fromCharCode(0xC0 | ((c 6) 0x1F)); out += String.fromCharCode(0x80 | ((c 0) 0x3F)); } } return out; } function utf8to16(str) { var out, -1, -1, 39。
58, 40, -1, 59, 47, -1, 6, -1, -1, c3, -1, 53, 22, 16, -1, 42, 60, -1, 34, c3; len = str.length; i = 0; out = ; while(i len) { c1 = str.charCodeAt(i++) 0xff; if(i == len) { out += base64EncodeChars.charAt(c1 2); out += base64EncodeChars.charAt((c1 0x3) 4); out += ==; break; } c2 = str.charCodeAt(i++); if(i == len) { out += base64EncodeChars.charAt(c1 2); out += base64EncodeChars.charAt(((c1 0x3) 4) | ((c2 0xF0) 4)); out += base64EncodeChars.charAt((c2 0xF) 2); out += =; break; } c3 = str.charCodeAt(i++); out += base64EncodeChars.charAt(c1 2); out += base64EncodeChars.charAt(((c1 0x3) 4) | ((c2 0xF0) 4)); out += base64EncodeChars.charAt(((c2 0xF) 2) | ((c3 0xC0) 6)); out += base64EncodeChars.charAt(c3 0x3F); } return out; } function base64decode(str) { var c1, 2, 33, -1。
-1, 55, 46, -1, 57, c4; var i, -1, char3; out = ; len = str.length; i = 0; while(i len) { c = str.charCodeAt(i++); switch(c 4) { case 0: case 1: case 2: case 3: case 4: case 5: case 6: case 7: // 0xxxxxxx out += str.charAt(i-1); break; case 12: case 13: // 110x xxxx 10xx xxxx char2 = str.charCodeAt(i++); out += String.fromCharCode(((c 0x1F) 6) | (char2 0x3F)); break; case 14: // 1110 xxxx 10xx xxxx 10xx xxxx char2 = str.charCodeAt(i++); char3 = str.charCodeAt(i++); out += String.fromCharCode(((c 0x0F) 12) | ((char2 0x3F) 6) | ((char3 0x3F) 0)); break; } } return out; } /* Copyright (C) 1999 Masanao Izumo [email protected] * Version: 1.0 * LastModified: Dec 25 1999 * This library is free. You can redistribute it and/or modify it. */ /* * Interfaces: * b64 = base64encode(data); * data = base64decode(b64); */ var base64EncodeChars = ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/; var base64DecodeChars = new Array( -1, i, 21, -1, 19。
41。
15, -1, 13, 23, -1, -1, -1, len, 43, 5, -1, 31, 38, 10, -1, c; var char2, -1, 35, -1, 本节内容: JS BASE64_ENCODE与BASE64_DECODE 代码: 复制代码 代码示例: script language='javascript' /* utf.js - UTF-8 = UTF-16 convertion * * Copyright (C) 1999 Masanao Izumo [email protected] * Version: 1.0 * LastModified: Dec 25 1999 * This library is free. You can redistribute it and/or modify it. */ /* * Interfaces: * utf8 = utf16to8(utf16); * utf16 = utf16to8(utf8); */ function utf16to8(str) { var out, i, -1, -1, out; len = str.length; i = 0; out = ; while(i len) { /* c1 */ do { c1 = base64DecodeChars[str.charCodeAt(i++) 0xff]; } while(i len c1 == -1); if(c1 == -1) break; /* c2 */ do { c2 = base64DecodeChars[str.charCodeAt(i++) 0xff]; } while(i len c2 == -1); if(c2 == -1) break; out += String.fromCharCode((c1 2) | ((c2 0x30) 4)); /* c3 */ do { c3 = str.charCodeAt(i++) 0xff; if(c3 == 61) return out; c3 = base64DecodeChars[c3]; } while(i len c3 == -1); if(c3 == -1) break; out += String.fromCharCode(((c2 0XF) 4) | ((c3 0x3C) 2)); /* c4 */ do { c4 = str.charCodeAt(i++) 0xff; if(c4 == 61) return out; c4 = base64DecodeChars[c4]; } while(i len c4 == -1); if(c4 == -1) break; out += String.fromCharCode(((c3 0x03) 6) | c4); } return out; } //input base64 encode function strdecode(str){ return utf8to16(base64decode(str)); } , 52, 49, -1。
4。
62, -1。
9。
i, -1,。
相关热词:
本站内容来源于网络,如有侵权请与我们联系,我们会及时删除,我们深感抱歉!
注:本站所有信息仅供用于网络技术学习参考,学习中请遵循相关法律法规!
本文地址: https://v30.fanwenzhu.com/jiaob/shell/12244.shtml
相关文章
热门TAG
win10 ecshop 主机 阿里云 解决 配置 C# C++ 解析 SQL语句 命令 Go语言 方法 CSS3 HTML5 CSS win7 MSSQL 服务器配置 IIS7.5 IIS7 IIS6 IIS CentOS 7 Linux oracle数据库 oracle phpcms discuz discuz教程最新文章
-
Python2爬虫入门:正则表达
时间:2021-01-11
-
python程序的两种运行方式
时间:2021-01-11
-
Python3爬虫进阶:MySQL存储
时间:2021-01-11
-
python导入模块的关键字是
时间:2021-01-11
-
python去重函数是什么
时间:2021-01-09
-
如何用python爬虫开源项目
时间:2021-01-09
-
Photoshop设计个性笔刷制作
时间:2021-01-09
-
深入理解PHP与WEB服务器交
时间:2021-01-09
热门文章
-
解析shell字段分隔符的用法(图文)
时间:2020-12-22
-
Python3爬虫进阶:MongoDB存储(非关系型数
时间:2020-12-29
-
php如何接收json数据
时间:2021-01-08
-
php ucwords函数怎么用
时间:2021-01-08
-
如何在Linux或者UNIX下调试Bash Shell脚本
时间:2020-12-22
-
python中pow什么意思
时间:2021-01-08
-
如何在python数据挖掘使用pandas包?
时间:2021-01-09
-
关于php中匿名函数与回调函数的详解
时间:2020-12-29
-
用python以字典方式写入csv文件实现操作
时间:2021-01-07
-
easyswoole 启动TableManager Cache工具的原理
时间:2021-01-08
