title: Input data must be multiple of cipher block size in AES CTR mode
body: <p>I get this exception when I use Dart's <a href="https://pub.dev/packages/encrypt" rel="nofollow noreferrer">encrypt package</a> to decrypt something using AES CTR mode:</p>
  
  <pre><code>E/flutter (19095): Invalid argument(s): Input data length must be a multiple of cipher's block size
  E/flutter (19095): #0      PaddedBlockCipherImpl.process (package:pointycastle/padded_block_cipher/padded_block_cipher_impl.dart:55:9)
  E/flutter (19095): #1      AES.decrypt (package:encrypt/src/algorithms/aes.dart:38:20)
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre><code>final encrypter = encrypt.Encrypter(encrypt.AES(key, mode: encrypt.AESMode.ctr));
  final decrypted = encrypter.decrypt(encrypt.Encrypted.fromBase16(cipher), iv: iv);
  </code></pre>
  
  <p><code>cipher</code> is hexadecimal string of length 10.  I thought AES CTR mode did not require any padding.  If it does require padding, what do I pad with?  I tried this:</p>
  
  <pre><code>final decrypted = encrypter.decrypt(encrypt.Encrypted.fromBase16(cipher.padRight(16, null)), iv: iv);
  </code></pre>
  
  <p>But I get the following exception:</p>
  
  <pre><code>E/flutter (19095): FormatException: Invalid radix-16 number (at character 1)
  E/flutter (19095): nu
  E/flutter (19095): ^
  </code></pre>
  
  <p>Using <code>'0'</code> as the padding results in the first exception I describe.</p>