empty string after decrypting
jraack opened this issue · comments
JRaack commented
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
Tim Kurvers commented
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.
Tim Kurvers commented
Did you manage to resolve this issue?
JRaack commented
Yes, by using the .swc, i had two libraries selected in my IDE. Something went wrong here. Thank you.
Tim Kurvers commented
Glad you got it resolved :)