timkurvers / as3-crypto

Fork of Henri Torgemane's excellent as3 cryptography library
http://code.google.com/p/as3crypto
Other
93 stars 46 forks source link

empty string after decrypting #10

Closed jraack closed 11 years ago

jraack commented 11 years ago

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

timkurvers commented 11 years ago

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.

timkurvers commented 11 years ago

Did you manage to resolve this issue?

jraack commented 11 years ago

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

timkurvers commented 11 years ago

Glad you got it resolved :)