Initialize local project and fix ranch growth synchronization

This commit is contained in:
AttilaNet
2026-11-07 22:14:49 +08:00
commit 657f5f33b5
1417 changed files with 202171 additions and 0 deletions
@@ -0,0 +1,173 @@
package com.hurlant.crypto
{
import com.hurlant.crypto.symmetric.AESKey;
import com.hurlant.crypto.symmetric.CBCMode;
import com.hurlant.crypto.symmetric.DESKey;
import com.hurlant.crypto.symmetric.ECBMode;
import com.hurlant.crypto.symmetric.IPad;
import com.hurlant.crypto.symmetric.TripleDESKey;
import com.hurlant.util.Hex;
import flash.utils.ByteArray;
import net.pixvi.pfw.utils.Paster;
import net.pixvi.pfw.utils.crypto.Base64;
public class Crypter
{
private static const cipher:Object = {};
public function Crypter()
{
super();
}
private static function strDecode(byteArr:ByteArray, mode:String) : String
{
switch(mode)
{
case "hex":
return Hex.fromArray(byteArr);
case "base64":
return Base64.Encode(byteArr);
default:
return null;
}
}
private static function strEncode(str:String, mode:String) : ByteArray
{
switch(mode)
{
case "hex":
return Hex.toArray(str);
case "base64":
return Base64.Decode(str);
default:
return null;
}
}
public static function aesEncode(str:String, key:String, strMode:String = "base64", keyMode:String = "base64") : String
{
var strByteArray:ByteArray = Paster.string2ByteArray(str);
aesBytesEncode(strByteArray,key,keyMode);
return strDecode(strByteArray,strMode);
}
public static function aesBytesEncode(bytes:ByteArray, key:String, keyMode:String = "base64") : void
{
var keyb:ByteArray = null;
var ecb:ECBMode = null;
var aes:AESKey = null;
var pad:IPad = null;
if(cipher[key] != null)
{
ecb = cipher[key];
}
else
{
if(keyMode == "base64")
{
keyb = Base64.Decode(key);
}
else if(keyMode == "hex")
{
keyb = Hex.toArray(key);
}
else
{
keyb = Paster.string2ByteArray(key);
}
aes = new AESKey(keyb);
pad = Crypto.getPad("pkcs5");
ecb = new ECBMode(aes,pad);
cipher[key] = ecb;
}
ecb.encrypt(bytes);
}
public static function aesDecode(aescode:String, key:String, strMode:String = "base64", keyMode:String = "base64") : String
{
var databyte:ByteArray = strEncode(aescode,strMode);
aesBytesDecode(databyte,key,keyMode);
return Paster.byteArray2String(databyte);
}
public static function aesBytesDecode(bytes:ByteArray, key:String, keyMode:String = "base64") : void
{
var keyb:ByteArray = null;
var ecb:ECBMode = null;
var aes:AESKey = null;
var pad:IPad = null;
if(cipher[key] != null)
{
ecb = cipher[key];
}
else
{
if(keyMode == "base64")
{
keyb = Base64.Decode(key);
}
else
{
keyb = Paster.string2ByteArray(key);
}
aes = new AESKey(keyb);
pad = Crypto.getPad("pkcs5");
ecb = new ECBMode(aes,pad);
cipher[key] = ecb;
}
ecb.decrypt(bytes);
}
public static function des3Encode(str:String, key:String, iv:String, strMode:String = "base64") : String
{
var keyb:ByteArray = Paster.string2ByteArray(key);
var ivb:ByteArray = Paster.string2ByteArray(iv);
var des:TripleDESKey = new TripleDESKey(keyb);
var cbc:CBCMode = new CBCMode(des);
cbc.IV = ivb;
var strByteArray:ByteArray = Paster.string2ByteArray(str);
cbc.encrypt(strByteArray);
return strDecode(strByteArray,strMode);
}
public static function des3Decode(des3code:String, key:String, iv:String, strMode:String = "base64") : String
{
var keyb:ByteArray = Paster.string2ByteArray(key);
var ivb:ByteArray = Paster.string2ByteArray(iv);
var des:TripleDESKey = new TripleDESKey(keyb);
var cbc:CBCMode = new CBCMode(des);
cbc.IV = ivb;
var databyte:ByteArray = strEncode(des3code,strMode);
cbc.decrypt(databyte);
return Paster.byteArray2String(databyte);
}
public static function desEncode(str:String, key:String, iv:String, strMode:String = "base64") : String
{
var keyb:ByteArray = Paster.string2ByteArray(key);
var ivb:ByteArray = Paster.string2ByteArray(iv);
var des:DESKey = new DESKey(keyb);
var cbc:CBCMode = new CBCMode(des);
cbc.IV = ivb;
var strByteArray:ByteArray = Paster.string2ByteArray(str);
cbc.encrypt(strByteArray);
return strDecode(strByteArray,strMode);
}
public static function desDecode(descode:String, key:String, iv:String, strMode:String = "base64") : String
{
var keyb:ByteArray = Paster.string2ByteArray(key);
var ivb:ByteArray = Paster.string2ByteArray(iv);
var des:DESKey = new DESKey(keyb);
var cbc:CBCMode = new CBCMode(des);
cbc.IV = ivb;
var databyte:ByteArray = Base64.Decode(descode);
cbc.decrypt(databyte);
return strDecode(databyte,strMode);
}
}
}