Initialize local project and fix ranch growth synchronization
This commit is contained in:
@@ -0,0 +1,70 @@
|
||||
package net.pixvi.myrcryptor
|
||||
{
|
||||
import com.adobe.crypto.MD5;
|
||||
import flash.filesystem.File;
|
||||
import flash.utils.ByteArray;
|
||||
import flash.utils.Dictionary;
|
||||
import net.pixvi.pfw.utils.core.Singleton;
|
||||
import net.pixvi.pse.file.FileTools;
|
||||
|
||||
public class MYRCryptor extends Singleton
|
||||
{
|
||||
|
||||
private static var bytearrUncompressDic:Dictionary = new Dictionary();
|
||||
|
||||
public function MYRCryptor()
|
||||
{
|
||||
super();
|
||||
}
|
||||
|
||||
public static function getHashSrcBytes(path:String) : ByteArray
|
||||
{
|
||||
var file:File = null;
|
||||
if(path.charAt(0) == "/")
|
||||
{
|
||||
path = path.slice(1);
|
||||
}
|
||||
path = getHashSrc(path);
|
||||
if(path.indexOf("app-storage:/") == 0)
|
||||
{
|
||||
file = new File(path);
|
||||
}
|
||||
else
|
||||
{
|
||||
file = FileTools.applicationDirectory.resolvePath(path);
|
||||
}
|
||||
if(!file.exists)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return FileTools.readFileBytes(file);
|
||||
}
|
||||
|
||||
public static function getHashSrc(src:String) : String
|
||||
{
|
||||
var prefix:String = "";
|
||||
if(src.indexOf("app-storage:/") == 0)
|
||||
{
|
||||
src = src.replace("app-storage:/","");
|
||||
prefix = "app-storage:/";
|
||||
}
|
||||
var md5:String = MD5.hash(src);
|
||||
return prefix + "codes/" + md5;
|
||||
}
|
||||
|
||||
public static function jsonDecodeHandler(bytearr:ByteArray) : Object
|
||||
{
|
||||
if(bytearrUncompressDic[bytearr] == null)
|
||||
{
|
||||
bytearr.uncompress();
|
||||
bytearrUncompressDic[bytearr] = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
bytearr.position = 0;
|
||||
}
|
||||
return bytearr.readObject();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user