package primary.utils
{
import flash.utils.ByteArray;
public class IiiEncryptionXor
{
public function IiiEncryptionXor()
{
super();
}
public static function encrypt(string:String, key:String) : String
{
var barr:ByteArray = new ByteArray();
barr.writeUTFBytes(Base64.encode(string));
var xstr:String = xorr(barr,key);
return Base64.encode(xstr);
}
public static function decrypt(string:String, key:String) : String
{
var barr:ByteArray = Base64.decodeToByteArray(string);
var xstr:String = xorr(barr,key);
return Base64.decode(xstr);
}
private static function xorr(barr:ByteArray, key:String) : String
{
var keypos:Number = NaN;
var keyByteArr:ByteArray = new ByteArray();
keyByteArr.writeUTFBytes(key);
var keylen:int = keyByteArr.length;
var barrlen:int = barr.length;
var barrNew:ByteArray = new ByteArray();
for(var i:int = 0; i < barrlen; i++)
{
keypos = i % keylen;
barrNew[i] = barr[i] ^ keyByteArr[keypos];
}
return barrNew.toString();
}
}
}
private const VERY_LONG:String = "some very-very long string without any non-latin characters due to different string representations inside of variable programming languages";
package primary.utils
{
import flash.utils.ByteArray;
public class Base64
{
private static const BASE64_CHARS:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
public static const version:String = "1.1.0";
public function Base64()
{
super();
throw new Error("Base64 class is static container only");
}
public static function encode(data:String) : String
{
var bytes:ByteArray = new ByteArray();
bytes.writeUTFBytes(data);
return encodeByteArray(bytes);
}
public static function encodeByteArray(data:ByteArray) : String
{
var dataBuffer:Array = null;
var i:uint = 0;
var j:uint = 0;
var k:uint = 0;
var output:String = "";
var outputBuffer:Array = new Array(4);
data.position = 0;
while(data.bytesAvailable > 0)
{
dataBuffer = new Array();
i = 0;
while(i < 3 && data.bytesAvailable > 0)
{
dataBuffer[i] = data.readUnsignedByte();
i++;
}
outputBuffer[0] = (dataBuffer[0] & 252) >> 2;
outputBuffer[1] = (dataBuffer[0] & 3) << 4 | dataBuffer[1] >> 4;
outputBuffer[2] = (dataBuffer[1] & 15) << 2 | dataBuffer[2] >> 6;
outputBuffer[3] = dataBuffer[2] & 63;
for(j = dataBuffer.length; j < 3; j++)
{
outputBuffer[j + 1] = 64;
}
for(k = 0; k < outputBuffer.length; k++)
{
output = output + BASE64_CHARS.charAt(outputBuffer[k]);
}
}
return output;
}
public static function decode(data:String) : String
{
var bytes:ByteArray = decodeToByteArray(data);
return bytes.readUTFBytes(bytes.length);
}
public static function decodeToByteArray(data:String) : ByteArray
{
var j:uint = 0;
var k:uint = 0;
var output:ByteArray = new ByteArray();
var dataBuffer:Array = new Array(4);
var outputBuffer:Array = new Array(3);
for(var i:uint = 0; i < data.length; i = i + 4)
{
j = 0;
while(j < 4 && i + j < data.length)
{
dataBuffer[j] = BASE64_CHARS.indexOf(data.charAt(i + j));
while(dataBuffer[j] < 0 && i < data.length)
{
i++;
dataBuffer[j] = BASE64_CHARS.indexOf(data.charAt(i + j));
}
j++;
}
outputBuffer[0] = (dataBuffer[0] << 2) + ((dataBuffer[1] & 48) >> 4);
outputBuffer[1] = ((dataBuffer[1] & 15) << 4) + ((dataBuffer[2] & 60) >> 2);
outputBuffer[2] = ((dataBuffer[2] & 3) << 6) + dataBuffer[3];
for(k = 0; k < outputBuffer.length; k++)
{
if(dataBuffer[k + 1] == 64)
{
break;
}
output.writeByte(outputBuffer[k]);
}
}
output.position = 0;
return output;
}
}
}
перерисует целиком свой виртуальный dom
let vueCallback
function vueInit (callback) {
vueCallback = callback
}
function vuePostMsg (msg, params) {
ppuApp.processMessage(msg, params)
}
window.vueInit = vueInit
window.vuePostMsg = vuePostMsg