[AS3]as3.0的Base64类代码
[AS3]as3.0的Base64类代码,as3的Base64,AS3的BASE64编码与解码类
[AS3]as3.0的Base64类代码
- package com.as3long.utils
- {
- /**
- * ...
- * @author 黄龙
- */
- public class Base64Url
- {
- public function Base64Url()
- {
- }
- public static function encode(str : String, utf8encode : Boolean = false) : String
- {
- var dataStr:String = Base64.encode(str, utf8encode);
- while (dataStr.charAt(dataStr.length - 1) == "=")
- {
- dataStrdataStr = dataStr.substring(0, dataStr.length - 1);
- }
- var myPattern:RegExp = /\+/g;
- dataStrdataStr =dataStr.replace(myPattern, "-")
- var myPattern2:RegExp = /\//g;
- dataStrdataStr = dataStr.replace(myPattern2, "_")
- return dataStr;
- }
- public static function decode(str : String, utf8decode : Boolean = false) : String
- {
- var dataStr:String = str;
- var complementNum:int = dataStr.length % 4;
- for (var i:int = 0; i < complementNum; i++)
- {
- dataStr += "=";
- }
- var myPattern:RegExp = /\-/g;
- dataStrdataStr =dataStr.replace(myPattern, "+")
- var myPattern2:RegExp = /\_/g;
- dataStrdataStr = dataStr.replace(myPattern2, "/")
- dataStr = Base64.decode(dataStr, utf8decode);
- return dataStr;
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...