as3crypto中出现"Invalid padding“错误的原因是什么?
Error: PKCS#5:unpad: Invalid padding value. expected [153], found [25]
at com.hurlant.crypto.symmetric::PKCS5/unpad()
at com.hurlant.crypto.symmetric::CTRMode/decrypt()
at com.hurlant.crypto.symmetric::SimpleIVMode/decrypt()
at com.mycompany.myproject::Application$/decrypt()
... (followed by the rest of my application stack)我想我以前已经解决了这个问题,通过使用SimpleIVMode包装类,确保加密的数据在前面加上初始化向量(IV)。在这种情况下,我已经在这么做了。
我没有使用Crypto类,因为最小化下载大小很重要。
有什么想法吗?
我的抽象代码(在Application类中):
protected static var cipher:ICipher =
new SimpleIVMode(
new CTRMode(
new AESKey( Hex.toArray("53c12a8eb8612733ec817290580c3d") // not actual key
))
);
public static function encrypt(d:ByteArray):ByteArray {
d.position = 0;
cipher.encrypt(d);
d.position = 0;
return d;
}
public static function decrypt(d:ByteArray):ByteArray {
d.position = 0;
cipher.decrypt(d); // THIS LINE THROWS
d.position = 0;
return d;
}所有那些d.position = 0的东西都是我的偏执狂。
加密代码:
// we first have to serialize the object to a ByteArray, then encrypt that data.
var encryptedValue:ByteArray = new ByteArray();
encryptedValue.writeObject(objectToEncrypt);
encryptedValue.position = 0; // paranoia?
Application.encrypt(encryptedValue);
so.setProperty(key, encryptedValue); // save it in my SharedObject现在,导致错误的代码如下:
var data:ByteArray = so.data[key]; // get the byte array out of storage.
trace(data.length); // Check that it's real... I get 553 bytes
Application.decrypt(data); // THIS LINE THROWS发布于 2010-09-01 11:44:29
我认为你应该扩展SharedObject的内存大小,比如
so.flush(1000000000000000);https://stackoverflow.com/questions/3614697
复制相似问题