Trying to redo the l2j password encryption in flash website
Posted: Sat Jul 20, 2013 12:05 am
Hello! I want my users to be able to log on my flash website, so I need to reproduce the l2j login password encryption on actionscript 3 (Is there maybe an easier way?)
So I found this code on LoginController.java
and below another encryption to base64 (Im not sure if Im missing another encryption)
I made this code for actionscript 3
But I'm not getting the same results, I think that has something to do with the UTF8 encoding, which is probably not an encryption:
Does anyone knows how to do that on AS3, or an easy way to do it?
Thx a lot
So I found this code on LoginController.java
Code: Select all
MessageDigest md = MessageDigest.getInstance("SHA"); byte[] raw = password.getBytes("UTF-8"); byte[] hash = md.digest(raw);
I made this code for actionscript 3
Code: Select all
Login_Usuario.Texto_Usuario.text = encodeUTF8 (Login_Usuario.Texto_Usuario.text); Login_Usuario.Texto_Usuario.text = SHA1.hash (Login_Usuario.Texto_Usuario.text); Login_Usuario.Texto_Usuario.text = Base64.encode(Login_Usuario.Texto_Usuario.text);
Code: Select all
function encodeUTF8 (text:String):String { var a:uint, n:uint, A:uint; var utf:String; utf = ""; A = text.length; for (a = 0; a < A; a++) { n = text.charCodeAt (a); if (n < 128) { utf += String.fromCharCode (n); } else if ((n > 127) && (n < 2048)) { utf += String.fromCharCode ((n >> 6) | 192); utf += String.fromCharCode ((n & 63) | 128); } else { utf += String.fromCharCode ((n >> 12) | 224); utf += String.fromCharCode (((n >> 6) & 63) | 128); utf += String.fromCharCode ((n & 63) | 128); } } return utf;}
Thx a lot