kolombet / as3crypto

Automatically exported from code.google.com/p/as3crypto
1 stars 0 forks source link

How to resolve bug RC4 encrypt-decrypt on iPAD with AIR15 only #79

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hi everybody,
I have some trouble with AIR15 only, In the past, I created a small game on 
iPad It could send or receive messge from server. I used lib as3crypto.swc 
encrypt or decrypt message (RC4). But when I upgrade to AIR15 encrypt-decrypt 
cannot work ( Another thing about this crash is that it only happens with a 
release (adhoc or appstore) build but NOT with a debug build). I check so many 
time but i don't know what is problem here.
Please help me, thanks so much any advice.

Class RC4.as

import com.hurlant.crypto.prng.ARC4;
import com.hurlant.util.Base64;
import com.hurlant.util.Hex;
import flash.utils.ByteArray;

public class RC4
{
  private static const key:String = "keytest";
  private static var byteKeys:ByteArray = Hex.toArray(Hex.fromString(key));
  private static var rc4:ARC4 = new ARC4();

  public static function encrypt(clearText:String):String
{
  var byteText:ByteArray = Hex.toArray(Hex.fromString(clearText));
  rc4.init(byteKeys);
  rc4.encrypt(byteText);
  return Base64.encodeByteArray(byteText);
}
public static function decrypt(encryptedText:String):String
{
  var byteText:ByteArray = Base64.decodeToByteArray(encryptedText);
  rc4.init(byteKeys);
  rc4.decrypt(byteText);
  return Hex.toString(Hex.fromArray(byteText));
}
}

Original issue reported on code.google.com by hoangsan...@gmail.com on 31 Oct 2014 at 8:35

GoogleCodeExporter commented 9 years ago
I have the same problem. It used to work for my login credentials but since the 
SDK 15 update not anymore.

If anyone has possible fixes, they would be very helpful.

Original comment by dr...@happymetrix.com on 4 Dec 2014 at 4:02

GoogleCodeExporter commented 9 years ago
I found a fix without using this .swc . You have to use the 
Base64Encoder/Decoder in .mx itself.

var bs:Base64Encoder = new Base64Encoder();
var ba:ByteArray = encrypter.compute( skB,  strB);
bs.encodeBytes(ba);
var stringToSign:String = bs.toString();

that gives you the same result and works with the new SDK

Original comment by dr...@happymetrix.com on 4 Dec 2014 at 6:55

GoogleCodeExporter commented 9 years ago
I resolved bug one month ago. So easy, The first step you got source code from 
here and after that You rebuild another SWC file (I used ExportSWC plugin in 
Flash Develop).Of sourse you got simple syntax error. Please fix immediately. I 
think the syntax in AIR SDK 15 is stronger old versions. You can do it.

P/S: You can review files below (Also customize RC4)

Original comment by hoangsan...@gmail.com on 16 Dec 2014 at 9:46

Attachments: