timkurvers / as3-crypto

Fork of Henri Torgemane's excellent as3 cryptography library

Home Page:http://code.google.com/p/as3crypto

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

empty string after decrypting

jraack opened this issue · comments

Hi all,

In flash i have this test to check if the encryption and decryption works;

 private function doTest(rsaPublic: RSAKey, rsaPrivate: RSAKey, message: String): Boolean
        {
            try {
                var src:ByteArray = Hex.toArray(Hex.fromString(message));
                var encrypted:ByteArray = new ByteArray();
                rsaPublic.encrypt(src, encrypted, src.length);

                var decrypted:ByteArray = new ByteArray();
                rsaPrivate.decrypt(encrypted, decrypted, encrypted.length);
                var original:String = Hex.toString(Hex.fromArray(decrypted));

                if (original != message) {
                    // original is empty
                }
            } catch (e: Error) {
                return false;
            }
            return true;
        }

i have a public and private key assigned;
PEM.readRSAPublicKey
PEM.readRSAPrivateKey

it returns true, but i have an empty string, it seems the decryption is not working well.

Hope someone can help.

grtz
Jay

Aren't you supposed to be returning false in the following branch:

if (original != message) {
    ...
}

Otherwise, that branch will fall through and indeed return true.

Did you manage to resolve this issue?

Yes, by using the .swc, i had two libraries selected in my IDE. Something went wrong here. Thank you.

Glad you got it resolved :)