title: Swift CryptoSwift library causing error "fatal error: Array index out of range"
body: <p>i have used CryptoSwift for AES encryption/decryption. when i run this code it throws error:</p>
  
  <blockquote>
    <p><strong>"fatal error: Array index out of range".</strong></p>
  </blockquote>
  
  <p>using reference from <a href="https://github.com/krzyzanowskim/CryptoSwift" rel="nofollow noreferrer">here</a></p>
  
  <p>What can be the cause for this?
  Any suggestion will be most appreciate.</p>
  
  <p>code:</p>
  
  <pre><code> let key = "1234567890123456" // key
     let iv = "1234567890123456" // random
     let message = "This is test string"
  
      override func viewDidLoad() {
          super.viewDidLoad()
  
      // encrypt
      let encrypted = AES(key: key, iv: iv, blockMode: .CBC)
      let enc =  encrypted?.encrypt(message.utf8Array, padding: PKCS7())
      println("enc &gt;&gt;  \(enc)")
  
      // decrypt
      let decrypted = AES(key: key, iv: iv, blockMode: .CBC)
      let dec =  encrypted?.decrypt(enc!, padding: PKCS7())
      println("dec &gt;&gt;  \(dec)")
  </code></pre>