Brought up to date with the private repository (feea4c7)

This commit is contained in:
S committed 2026-10-14 20:57:33 +03:00
1 parent 1aa738d692
commit 1b1df1ae48
7925 files changed
+2617237 -20

No files matched your search

@@ -0,0 +1,164 @@
package com.adobe.crypto
{
import com.adobe.utils.IntUtil;
public class MD5
{
public function MD5()
{
super();
}
public static function hash(s:String) : String
{
var aa:int = 0;
var bb:int = 0;
var cc:int = 0;
var dd:int = 0;
var a:int = 1732584193;
var b:int = -271733879;
var c:int = -1732584194;
var d:int = 271733878;
var x:Array = createBlocks(s);
var len:int = int(x.length);
for(var i:int = 0; i < len; i += 16)
{
aa = a;
bb = b;
cc = c;
dd = d;
a = ff(a,b,c,d,x[i + 0],7,-680876936);
d = ff(d,a,b,c,x[i + 1],12,-389564586);
c = ff(c,d,a,b,x[i + 2],17,606105819);
b = ff(b,c,d,a,x[i + 3],22,-1044525330);
a = ff(a,b,c,d,x[i + 4],7,-176418897);
d = ff(d,a,b,c,x[i + 5],12,1200080426);
c = ff(c,d,a,b,x[i + 6],17,-1473231341);
b = ff(b,c,d,a,x[i + 7],22,-45705983);
a = ff(a,b,c,d,x[i + 8],7,1770035416);
d = ff(d,a,b,c,x[i + 9],12,-1958414417);
c = ff(c,d,a,b,x[i + 10],17,-42063);
b = ff(b,c,d,a,x[i + 11],22,-1990404162);
a = ff(a,b,c,d,x[i + 12],7,1804603682);
d = ff(d,a,b,c,x[i + 13],12,-40341101);
c = ff(c,d,a,b,x[i + 14],17,-1502002290);
b = ff(b,c,d,a,x[i + 15],22,1236535329);
a = gg(a,b,c,d,x[i + 1],5,-165796510);
d = gg(d,a,b,c,x[i + 6],9,-1069501632);
c = gg(c,d,a,b,x[i + 11],14,643717713);
b = gg(b,c,d,a,x[i + 0],20,-373897302);
a = gg(a,b,c,d,x[i + 5],5,-701558691);
d = gg(d,a,b,c,x[i + 10],9,38016083);
c = gg(c,d,a,b,x[i + 15],14,-660478335);
b = gg(b,c,d,a,x[i + 4],20,-405537848);
a = gg(a,b,c,d,x[i + 9],5,568446438);
d = gg(d,a,b,c,x[i + 14],9,-1019803690);
c = gg(c,d,a,b,x[i + 3],14,-187363961);
b = gg(b,c,d,a,x[i + 8],20,1163531501);
a = gg(a,b,c,d,x[i + 13],5,-1444681467);
d = gg(d,a,b,c,x[i + 2],9,-51403784);
c = gg(c,d,a,b,x[i + 7],14,1735328473);
b = gg(b,c,d,a,x[i + 12],20,-1926607734);
a = hh(a,b,c,d,x[i + 5],4,-378558);
d = hh(d,a,b,c,x[i + 8],11,-2022574463);
c = hh(c,d,a,b,x[i + 11],16,1839030562);
b = hh(b,c,d,a,x[i + 14],23,-35309556);
a = hh(a,b,c,d,x[i + 1],4,-1530992060);
d = hh(d,a,b,c,x[i + 4],11,1272893353);
c = hh(c,d,a,b,x[i + 7],16,-155497632);
b = hh(b,c,d,a,x[i + 10],23,-1094730640);
a = hh(a,b,c,d,x[i + 13],4,681279174);
d = hh(d,a,b,c,x[i + 0],11,-358537222);
c = hh(c,d,a,b,x[i + 3],16,-722521979);
b = hh(b,c,d,a,x[i + 6],23,76029189);
a = hh(a,b,c,d,x[i + 9],4,-640364487);
d = hh(d,a,b,c,x[i + 12],11,-421815835);
c = hh(c,d,a,b,x[i + 15],16,530742520);
b = hh(b,c,d,a,x[i + 2],23,-995338651);
a = ii(a,b,c,d,x[i + 0],6,-198630844);
d = ii(d,a,b,c,x[i + 7],10,1126891415);
c = ii(c,d,a,b,x[i + 14],15,-1416354905);
b = ii(b,c,d,a,x[i + 5],21,-57434055);
a = ii(a,b,c,d,x[i + 12],6,1700485571);
d = ii(d,a,b,c,x[i + 3],10,-1894986606);
c = ii(c,d,a,b,x[i + 10],15,-1051523);
b = ii(b,c,d,a,x[i + 1],21,-2054922799);
a = ii(a,b,c,d,x[i + 8],6,1873313359);
d = ii(d,a,b,c,x[i + 15],10,-30611744);
c = ii(c,d,a,b,x[i + 6],15,-1560198380);
b = ii(b,c,d,a,x[i + 13],21,1309151649);
a = ii(a,b,c,d,x[i + 4],6,-145523070);
d = ii(d,a,b,c,x[i + 11],10,-1120210379);
c = ii(c,d,a,b,x[i + 2],15,718787259);
b = ii(b,c,d,a,x[i + 9],21,-343485551);
a += aa;
b += bb;
c += cc;
d += dd;
}
return IntUtil.toHex(a) + IntUtil.toHex(b) + IntUtil.toHex(c) + IntUtil.toHex(d);
}
private static function f(x:int, y:int, z:int) : int
{
return x & y | ~x & z;
}
private static function g(x:int, y:int, z:int) : int
{
return x & z | y & ~z;
}
private static function h(x:int, y:int, z:int) : int
{
return x ^ y ^ z;
}
private static function i(x:int, y:int, z:int) : int
{
return y ^ (x | ~z);
}
private static function transform(func:Function, a:int, b:int, c:int, d:int, x:int, s:int, t:int) : int
{
var tmp:int = a + int(func(b,c,d)) + x + t;
return IntUtil.rol(tmp,s) + b;
}
private static function ff(a:int, b:int, c:int, d:int, x:int, s:int, t:int) : int
{
return transform(f,a,b,c,d,x,s,t);
}
private static function gg(a:int, b:int, c:int, d:int, x:int, s:int, t:int) : int
{
return transform(g,a,b,c,d,x,s,t);
}
private static function hh(a:int, b:int, c:int, d:int, x:int, s:int, t:int) : int
{
return transform(h,a,b,c,d,x,s,t);
}
private static function ii(a:int, b:int, c:int, d:int, x:int, s:int, t:int) : int
{
return transform(i,a,b,c,d,x,s,t);
}
private static function createBlocks(s:String) : Array
{
var blocks:Array = new Array();
var len:int = s.length * 8;
var mask:int = 255;
for(var i:int = 0; i < len; i += 8)
{
blocks[i >> 5] |= (s.charCodeAt(i / 8) & mask) << i % 32;
}
blocks[len >> 5] |= 128 << len % 32;
blocks[(len + 64 >>> 9 << 4) + 14] = len;
return blocks;
}
}
}
@@ -0,0 +1,24 @@
package com.adobe.serialization.json
{
public class JSON
{
public function JSON()
{
super();
}
public static function encode(o:Object) : String
{
var encoder:JSONEncoder = new JSONEncoder(o);
return encoder.getString();
}
public static function decode(s:String) : *
{
var decoder:JSONDecoder = new JSONDecoder(s);
return decoder.getValue();
}
}
}
@@ -0,0 +1,125 @@
package com.adobe.serialization.json
{
public class JSONDecoder
{
private var value:*;
private var tokenizer:JSONTokenizer;
private var token:JSONToken;
public function JSONDecoder(s:String)
{
super();
this.tokenizer = new JSONTokenizer(s);
this.nextToken();
this.value = this.parseValue();
}
public function getValue() : *
{
return this.value;
}
private function nextToken() : JSONToken
{
return this.token = this.tokenizer.getNextToken();
}
private function parseArray() : Array
{
var a:Array = new Array();
this.nextToken();
if(this.token.type == JSONTokenType.RIGHT_BRACKET)
{
return a;
}
while(true)
{
a.push(this.parseValue());
this.nextToken();
if(this.token.type == JSONTokenType.RIGHT_BRACKET)
{
return a;
}
if(this.token.type == JSONTokenType.COMMA)
{
this.nextToken();
}
else
{
this.tokenizer.parseError("Expecting ] or , but found " + this.token.value);
}
}
return null;
}
private function parseObject() : Object
{
var key:String = null;
var o:Object = new Object();
this.nextToken();
if(this.token.type == JSONTokenType.RIGHT_BRACE)
{
return o;
}
while(true)
{
if(this.token.type == JSONTokenType.STRING)
{
key = String(this.token.value);
this.nextToken();
if(this.token.type == JSONTokenType.COLON)
{
this.nextToken();
o[key] = this.parseValue();
this.nextToken();
if(this.token.type == JSONTokenType.RIGHT_BRACE)
{
return o;
}
if(this.token.type == JSONTokenType.COMMA)
{
this.nextToken();
}
else
{
this.tokenizer.parseError("Expecting } or , but found " + this.token.value);
}
}
else
{
this.tokenizer.parseError("Expecting : but found " + this.token.value);
}
}
else
{
this.tokenizer.parseError("Expecting string but found " + this.token.value);
}
}
return null;
}
private function parseValue() : Object
{
switch(this.token.type)
{
case JSONTokenType.LEFT_BRACE:
return this.parseObject();
case JSONTokenType.LEFT_BRACKET:
return this.parseArray();
case JSONTokenType.STRING:
case JSONTokenType.NUMBER:
case JSONTokenType.TRUE:
case JSONTokenType.FALSE:
case JSONTokenType.NULL:
return this.token.value;
default:
this.tokenizer.parseError("Unexpected " + this.token.value);
return null;
}
}
}
}
@@ -0,0 +1,146 @@
package com.adobe.serialization.json
{
import flash.utils.describeType;
public class JSONEncoder
{
private var jsonString:String;
public function JSONEncoder(value:*)
{
super();
this.jsonString = this.convertToString(value);
}
public function getString() : String
{
return this.jsonString;
}
private function convertToString(value:*) : String
{
if(value is String)
{
return this.escapeString(value as String);
}
if(value is Number)
{
return isFinite(value as Number) ? value.toString() : "null";
}
if(value is Boolean)
{
return Boolean(value) ? "true" : "false";
}
if(value is Array)
{
return this.arrayToString(value as Array);
}
if(value is Object && value != null)
{
return this.objectToString(value);
}
return "null";
}
private function escapeString(str:String) : String
{
var ch:String = null;
var hexCode:String = null;
var zeroPad:String = null;
var s:String = "";
var len:Number = str.length;
for(var i:int = 0; i < len; i++)
{
ch = str.charAt(i);
switch(ch)
{
case "\"":
s += "\\\"";
break;
case "\\":
s += "\\\\";
break;
case "\b":
s += "\\b";
break;
case "\f":
s += "\\f";
break;
case "\n":
s += "\\n";
break;
case "\r":
s += "\\r";
break;
case "\t":
s += "\\t";
break;
default:
if(ch < " ")
{
hexCode = ch.charCodeAt(0).toString(16);
zeroPad = hexCode.length == 2 ? "00" : "000";
s += "\\u" + zeroPad + hexCode;
}
else
{
s += ch;
}
}
}
return "\"" + s + "\"";
}
private function arrayToString(a:Array) : String
{
var s:String = "";
for(var i:int = 0; i < a.length; i++)
{
if(s.length > 0)
{
s += ",";
}
s += this.convertToString(a[i]);
}
return "[" + s + "]";
}
private function objectToString(o:Object) : String
{
var value:Object = null;
var key:String = null;
var v:XML = null;
var s:String = "";
var classInfo:XML = describeType(o);
if(classInfo.@name.toString() == "Object")
{
for(key in o)
{
value = o[key];
if(!(value is Function))
{
if(s.length > 0)
{
s += ",";
}
s += this.escapeString(key) + ":" + this.convertToString(value);
}
}
}
else
{
for each(v in classInfo..*.(name() == "variable" || name() == "accessor"))
{
if(s.length > 0)
{
s += ",";
}
s += this.escapeString(v.@name.toString()) + ":" + this.convertToString(o[v.@name]);
}
}
return "{" + s + "}";
}
}
}
@@ -0,0 +1,28 @@
package com.adobe.serialization.json
{
public class JSONParseError extends Error
{
private var _location:int;
private var _text:String;
public function JSONParseError(message:String = "", location:int = 0, text:String = "")
{
super(message);
this._location = location;
this._text = text;
}
public function get location() : int
{
return this._location;
}
public function get text() : String
{
return this._text;
}
}
}
@@ -0,0 +1,38 @@
package com.adobe.serialization.json
{
public class JSONToken
{
private var _type:int;
private var _value:Object;
public function JSONToken(type:int = -1, value:Object = null)
{
super();
this._type = type;
this._value = value;
}
public function get type() : int
{
return this._type;
}
public function set type(value:int) : void
{
this._type = value;
}
public function get value() : Object
{
return this._value;
}
public function set value(v:Object) : void
{
this._value = v;
}
}
}
@@ -0,0 +1,36 @@
package com.adobe.serialization.json
{
public class JSONTokenType
{
public static const UNKNOWN:int = -1;
public static const COMMA:int = 0;
public static const LEFT_BRACE:int = 1;
public static const RIGHT_BRACE:int = 2;
public static const LEFT_BRACKET:int = 3;
public static const RIGHT_BRACKET:int = 4;
public static const COLON:int = 6;
public static const TRUE:int = 7;
public static const FALSE:int = 8;
public static const NULL:int = 9;
public static const STRING:int = 10;
public static const NUMBER:int = 11;
public function JSONTokenType()
{
super();
}
}
}
@@ -0,0 +1,350 @@
package com.adobe.serialization.json
{
public class JSONTokenizer
{
private var obj:Object;
private var jsonString:String;
private var loc:int;
private var ch:String;
public function JSONTokenizer(s:String)
{
super();
this.jsonString = s;
this.loc = 0;
this.nextChar();
}
public function getNextToken() : JSONToken
{
var possibleTrue:String = null;
var possibleFalse:String = null;
var possibleNull:String = null;
var token:JSONToken = new JSONToken();
this.skipIgnored();
switch(this.ch)
{
case "{":
token.type = JSONTokenType.LEFT_BRACE;
token.value = "{";
this.nextChar();
break;
case "}":
token.type = JSONTokenType.RIGHT_BRACE;
token.value = "}";
this.nextChar();
break;
case "[":
token.type = JSONTokenType.LEFT_BRACKET;
token.value = "[";
this.nextChar();
break;
case "]":
token.type = JSONTokenType.RIGHT_BRACKET;
token.value = "]";
this.nextChar();
break;
case ",":
token.type = JSONTokenType.COMMA;
token.value = ",";
this.nextChar();
break;
case ":":
token.type = JSONTokenType.COLON;
token.value = ":";
this.nextChar();
break;
case "t":
possibleTrue = "t" + this.nextChar() + this.nextChar() + this.nextChar();
if(possibleTrue == "true")
{
token.type = JSONTokenType.TRUE;
token.value = true;
this.nextChar();
}
else
{
this.parseError("Expecting \'true\' but found " + possibleTrue);
}
break;
case "f":
possibleFalse = "f" + this.nextChar() + this.nextChar() + this.nextChar() + this.nextChar();
if(possibleFalse == "false")
{
token.type = JSONTokenType.FALSE;
token.value = false;
this.nextChar();
}
else
{
this.parseError("Expecting \'false\' but found " + possibleFalse);
}
break;
case "n":
possibleNull = "n" + this.nextChar() + this.nextChar() + this.nextChar();
if(possibleNull == "null")
{
token.type = JSONTokenType.NULL;
token.value = null;
this.nextChar();
}
else
{
this.parseError("Expecting \'null\' but found " + possibleNull);
}
break;
case "\"":
token = this.readString();
break;
default:
if(this.isDigit(this.ch) || this.ch == "-")
{
token = this.readNumber();
}
else
{
if(this.ch == "")
{
return null;
}
this.parseError("Unexpected " + this.ch + " encountered");
}
}
return token;
}
private function readString() : JSONToken
{
var hexValue:String = null;
var i:int = 0;
var token:JSONToken = new JSONToken();
token.type = JSONTokenType.STRING;
var string:String = "";
this.nextChar();
while(this.ch != "\"" && this.ch != "")
{
if(this.ch == "\\")
{
this.nextChar();
switch(this.ch)
{
case "\"":
string += "\"";
break;
case "/":
string += "/";
break;
case "\\":
string += "\\";
break;
case "b":
string += "\b";
break;
case "f":
string += "\f";
break;
case "n":
string += "\n";
break;
case "r":
string += "\r";
break;
case "t":
string += "\t";
break;
case "u":
hexValue = "";
for(i = 0; i < 4; i++)
{
if(!this.isHexDigit(this.nextChar()))
{
this.parseError(" Excepted a hex digit, but found: " + this.ch);
}
hexValue += this.ch;
}
string += String.fromCharCode(parseInt(hexValue,16));
break;
default:
string += "\\" + this.ch;
}
}
else
{
string += this.ch;
}
this.nextChar();
}
if(this.ch == "")
{
this.parseError("Unterminated string literal");
}
this.nextChar();
token.value = string;
return token;
}
private function readNumber() : JSONToken
{
var token:JSONToken = new JSONToken();
token.type = JSONTokenType.NUMBER;
var input:String = "";
if(this.ch == "-")
{
input += "-";
this.nextChar();
}
if(!this.isDigit(this.ch))
{
this.parseError("Expecting a digit");
}
if(this.ch == "0")
{
input += this.ch;
this.nextChar();
if(this.isDigit(this.ch))
{
this.parseError("A digit cannot immediately follow 0");
}
}
else
{
while(this.isDigit(this.ch))
{
input += this.ch;
this.nextChar();
}
}
if(this.ch == ".")
{
input += ".";
this.nextChar();
if(!this.isDigit(this.ch))
{
this.parseError("Expecting a digit");
}
while(this.isDigit(this.ch))
{
input += this.ch;
this.nextChar();
}
}
if(this.ch == "e" || this.ch == "E")
{
input += "e";
this.nextChar();
if(this.ch == "+" || this.ch == "-")
{
input += this.ch;
this.nextChar();
}
if(!this.isDigit(this.ch))
{
this.parseError("Scientific notation number needs exponent value");
}
while(this.isDigit(this.ch))
{
input += this.ch;
this.nextChar();
}
}
var num:Number = Number(input);
if(isFinite(num) && !isNaN(num))
{
token.value = num;
return token;
}
this.parseError("Number " + num + " is not valid!");
return null;
}
private function nextChar() : String
{
return this.ch = this.jsonString.charAt(this.loc++);
}
private function skipIgnored() : void
{
this.skipWhite();
this.skipComments();
this.skipWhite();
}
private function skipComments() : void
{
if(this.ch == "/")
{
this.nextChar();
switch(this.ch)
{
case "/":
do
{
this.nextChar();
}
while(this.ch != "\n" && this.ch != "");
this.nextChar();
break;
case "*":
this.nextChar();
while(true)
{
if(this.ch == "*")
{
this.nextChar();
if(this.ch == "/")
{
this.nextChar();
break;
}
}
else
{
this.nextChar();
}
if(this.ch == "")
{
this.parseError("Multi-line comment not closed");
}
}
break;
default:
this.parseError("Unexpected " + this.ch + " encountered (expecting \'/\' or \'*\' )");
}
}
}
private function skipWhite() : void
{
while(this.isWhiteSpace(this.ch))
{
this.nextChar();
}
}
private function isWhiteSpace(ch:String) : Boolean
{
return ch == " " || ch == "\t" || ch == "\n";
}
private function isDigit(ch:String) : Boolean
{
return ch >= "0" && ch <= "9";
}
private function isHexDigit(ch:String) : Boolean
{
var uc:String = ch.toUpperCase();
return this.isDigit(ch) || uc >= "A" && uc <= "F";
}
public function parseError(message:String) : void
{
throw new JSONParseError(message,this.loc,this.jsonString);
}
}
}
@@ -0,0 +1,47 @@
package com.adobe.utils
{
public class IntUtil
{
private static var hexChars:String = "0123456789abcdef";
public function IntUtil()
{
super();
}
public static function rol(x:int, n:int) : int
{
return x << n | x >>> 32 - n;
}
public static function ror(x:int, n:int) : uint
{
var nn:int = 32 - n;
return x << nn | x >>> 32 - nn;
}
public static function toHex(n:int, bigEndian:Boolean = false) : String
{
var i:int = 0;
var x:int = 0;
var s:String = "";
if(bigEndian)
{
for(i = 0; i < 4; i++)
{
s += hexChars.charAt(n >> (3 - i) * 8 + 4 & 0x0F) + hexChars.charAt(n >> (3 - i) * 8 & 0x0F);
}
}
else
{
for(x = 0; x < 4; x++)
{
s += hexChars.charAt(n >> x * 8 + 4 & 0x0F) + hexChars.charAt(n >> x * 8 & 0x0F);
}
}
return s;
}
}
}
@@ -0,0 +1,99 @@
package com.adobe.utils
{
public class StringUtil
{
public function StringUtil()
{
super();
}
public static function stringsAreEqual(s1:String, s2:String, caseSensitive:Boolean) : Boolean
{
if(caseSensitive)
{
return s1 == s2;
}
return s1.toUpperCase() == s2.toUpperCase();
}
public static function trim(input:String) : String
{
return StringUtil.ltrim(StringUtil.rtrim(input));
}
public static function ltrim(input:String) : String
{
var size:Number = input.length;
for(var i:Number = 0; i < size; i++)
{
if(input.charCodeAt(i) > 32)
{
return input.substring(i);
}
}
return "";
}
public static function rtrim(input:String) : String
{
var size:Number = input.length;
for(var i:Number = size; i > 0; i--)
{
if(input.charCodeAt(i - 1) > 32)
{
return input.substring(0,i);
}
}
return "";
}
public static function beginsWith(input:String, prefix:String) : Boolean
{
return prefix == input.substring(0,prefix.length);
}
public static function endsWith(input:String, suffix:String) : Boolean
{
return suffix == input.substring(input.length - suffix.length);
}
public static function remove(input:String, remove:String) : String
{
return StringUtil.replace(input,remove,"");
}
public static function replace(input:String, replace:String, replaceWith:String) : String
{
var j:Number = NaN;
var sb:String = new String();
var found:Boolean = false;
var sLen:Number = input.length;
var rLen:Number = replace.length;
for(var i:Number = 0; i < sLen; i++)
{
if(input.charAt(i) == replace.charAt(0))
{
found = true;
for(j = 0; j < rLen; j++)
{
if(input.charAt(i + j) != replace.charAt(j))
{
found = false;
break;
}
}
if(found)
{
sb += replaceWith;
i += rLen - 1;
continue;
}
}
sb += input.charAt(i);
}
return sb;
}
}
}