Skip to content

Instantly share code, notes, and snippets.

@wodim
Created February 18, 2014 13:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save wodim/242378945f465433ed5f to your computer and use it in GitHub Desktop.
Save wodim/242378945f465433ed5f to your computer and use it in GitHub Desktop.
public function descifra_ip(cookie:String, claveCifrado:String) : String {
var t:ByteArray = Base64.decodeToByteArray(cookie);
var k:ByteArray = Base64.decodeToByteArray(claveCifrado);
var v:ByteArray = new ByteArray();
var v2:ByteArray = new ByteArray();
var v3:ByteArray = new ByteArray();
var r:ByteArray = new ByteArray();
k.position = 24;
k.writeBytes(t,0,8);
v.writeBytes(t,8,16);
k.position = 0;
v.position = 0;
var aes:AESKey = new AESKey(k);
var i:int = 8;
while(i < t.length)
{
v.position = 0;
v2.position = 0;
v3.position = 0;
v.writeBytes(t,i,16);
v3.writeBytes(v,0,16);
aes.decrypt(v);
this.xor(v,v2);
v2.writeBytes(v3,0,16);
r.writeBytes(v,0,16);
i = i + 16;
}
aes.dispose();
var resultado:String = r.toString();
return resultado;
}
public function xor(destino:ByteArray, origen:ByteArray) : void {
var i:int = 0;
while(i < destino.length)
{
destino[i] = destino[i] ^ origen[i];
i++;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment