title: CryptoSwift AES128-CBC with Swift
body: <p>I'm getting this error while decrypting an AES128CBC encrypted JSON:</p>
  
  <blockquote>
    <p>assertion failed: Block size and Initialization Vector must be the
    same length!: file ##### for
    iOS/CryptoSwift/Sources/CryptoSwift/AES.swift, line 97</p>
  </blockquote>
  
  <p>I'm using the CryptoSwift Framework with the latest Xcode.</p>
  
  <p>My Method:</p>
  
  <pre><code>func aes128(key: String, iv: String) throws -&gt; String?{
          if let aes: AES = try AES(key: key, iv: iv, blockMode: .CBC){
              if let encrypted: [UInt8] = try aes.encrypt([UInt8](self.utf8), padding: PKCS7()){
                  return String(data: NSData.withBytes(encrypted), encoding: NSUTF8StringEncoding)
              }
          }
  
          return nil
  }
  </code></pre>
  
  <p>Call:</p>
  
  <pre><code>do{
      print(try dataStr.aes128("8e0c0e73f97f2eb386ad75ba86051334", iv: "aa17ffc4ea4b1eac8fa0b56872f34e5f"))   
  }catch{
  
  }
  </code></pre>