2010-09-01 63 views
0

as3crypto中錯誤「Invalid padding value」的原因是什麼?爲什麼as3crypto會說「無效的填充值」?

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) 

我覺得我以前通過確保加密數據(IV),通過使用SimpleIVMode包裝類與intialization載體前綴解決了這個。在這種情況下,我已經這麼做了。

我沒有使用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 

回答

0

我想你應該延長您的共享對象的內存大小一樣

so.flush(1000000000000000); 
+0

嗯 - 我試過了,沒有用。感謝這個想法。 – aaaidan 2010-09-01 05:10:36

+0

那我想你應該仔細檢查alghoritms – Eugene 2010-09-01 13:55:02

相關問題