title: Padding error in as3Crypto when trying to work a-sync
body: <p>I'm trying to encrypt/decrypt files in flex (AIR) using the <em>as3crypto</em> package.
  the problem is that when attempting to process slightly large files (over 5M) the process time gets ridiculously long and the client freezes (get the "not responding" title)
  so i tried to go Async and encrypt/decrypt a chunk at a time and interlace it with the frame refresh rate.</p>
  
  <p>the encryption goes smooth, or so it seems, but when i try to decrypt the result back to the original document i get a padding error:
  "<strong>Error: PKCS#5:unpad: Invalid padding value. expected [252], found [152]</strong>"</p>
  
  <p>my code is like so (between initiation and finalization):</p>
  
  <ul>
  <li>the <strong>run</strong> method gets called repeatedly until the file is completed</li>
  <li>_<strong>buffer</strong> contains the byte array from the source file</li>
  <li>_<strong>result</strong> the result</li>
  <li><strong>CHUNK</strong> is the bite size of bytes that i process each time</li>
  <li><p>the cipher is initiated as: Crypto.getCipher("aes-ecb", _key, Crypto.getPad("pkcs5"));</p>
  
  <pre><code>public function run(data:Object):Boolean{
  
      if((_buffer.length-_position)&gt;CHUNK){
          processChunk(_position,CHUNK);
          _position += CHUNK;
          var e:ProgressEvent = new ProgressEvent(ProgressEvent.PROGRESS,false,false,_position,_buffer.length);
          this.dispatchEvent(e);
          return true;
      }else if(!_isFinnalized){
          processChunk(_position,_buffer.length - _position);
          this.dispatchEvent(new Event(Event.COMPLETE));
          finnalize();
  
      }
  
      return false;
  }
  
  
  private function processChunk(position:uint,chunk:uint):void{
      var buffer:ByteArray = new ByteArray();
      buffer.writeBytes(_buffer,position,chunk);
       if(_action==ENCRYPT){
          _aes.encrypt(buffer);
      }else{
          _aes.decrypt(buffer);
      } 
      _result.writeBytes(buffer);
  
  
  }
  </code></pre></li>
  </ul>
  
  <p>help me, please!</p>