Skip to content

Instantly share code, notes, and snippets.

@wodim wodim/gist:2691044
Last active Oct 4, 2015

Embed
What would you like to do?
Función «descifra» del webchat de IRC-Hispano - Terra
public function descifra(ping:String, claveCifrado:String) : String
{
var t:ByteArray = Base64.decodeToByteArray(ping);
var k:ByteArray = Base64.decodeToByteArray(claveCifrado);
var v: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);
aes.decrypt(v);
aes.dispose();
var tmp:String = v.toString().toUpperCase();
var rnd:Random = new Random();
rnd.autoSeed();
var s:ByteArray = new ByteArray();
rnd.nextBytes(s,8);
k = Base64.decodeToByteArray(claveCifrado);
k.position = 24;
k.writeBytes(s,0,8);
k.position = 0;
v.position = 0;
v.writeMultiByte(tmp,"us-ascii");
var aes2:AESKey = new AESKey(k);
aes2.encrypt(v);
aes2.dispose();
var r:ByteArray = new ByteArray();
r.writeBytes(s,0,8);
r.position = 8;
r.writeBytes(v,0,16);
r.position = 0;
var resultado:String = Base64.encodeByteArray(r);
return resultado;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.