title: how to encrypt in swift like android cipher?
body: <p>hi i am developing app in android and swift, encrypt in android using</p>
  
  <pre><code> public static String Encrypt(String text, String key)
          throws Exception {
      Cipher cipher = Cipher.getInstance("AES/CBC/PKCS5Padding");
      byte[] keyBytes= new byte[16];
      byte[] b= key.getBytes("UTF-8");
      int len= b.length;
      if (len &gt; keyBytes.length) len = keyBytes.length;
      System.arraycopy(b, 0, keyBytes, 0, len);
      SecretKeySpec keySpec = new SecretKeySpec(keyBytes, "AES");
      IvParameterSpec ivSpec = new IvParameterSpec(keyBytes);
      cipher.init(Cipher.ENCRYPT_MODE,keySpec,ivSpec);
  
      byte[] results = cipher.doFinal(text.getBytes("UTF-8"));
      BASE64Encoder encoder;
      encoder = new BASE64Encoder();
      return encoder.encode(results);
  }
  </code></pre>
  
  <p>and server side using RIJnadal lgorithm to get it but swift side i am using Cryptoswift library </p>
  
  <pre><code>        let key = privateKey // length == 3
  
      let iv = "0123456789" // lenght == 16
  
      let s = string
      let enc = try! s.aesEncrypt(key, iv: iv)
      let dec = try! enc.aesDecrypt(key, iv: iv)
      print(s) //string to encrypt
      print("enc:\(enc)") //2r0+KirTTegQfF4wI8rws0LuV8h82rHyyYz7xBpXIpM=
      print("dec:\(dec)") //string to encrypt
      print("\(s == dec)") //true
  </code></pre>
  
  <p>it produce error Block size and Initialization Vector must be the same length!
  how to fix </p>