title: How to do AES decryption using iv & key with cryptoswift?
body: <p>Implemented in javascript using cryptojs but unable to do the same in swift using cryptoswift. I am unable to understand how key, iv &amp; ciphertext are generated in javascript looking at the below code. Out of ideas to do the same in Swift using cryptoswift.</p>
  
  <pre><code>decryptPayloadQR(ciphertextStr, SecretKey) {
  
  try {
       let key = CryptoJS.enc.Utf8.parse(SecretKey);
       var ciphertext = CryptoJS.enc.Base64.parse(ciphertextStr);
       var iv = ciphertext.clone();
       iv.sigBytes = 16;
       iv.clamp();
       ciphertext.words.splice(0, 4);
       ciphertext.sigBytes -= 16;
       var decrypted = CryptoJS.AES.decrypt({ ciphertext: ciphertext }, key, {
         iv: iv
       });
       console.log("===decrypted.toString(CryptoJS.enc.Utf8)=",decrypted.toString(CryptoJS.enc.Utf8));
       return decrypted.toString(CryptoJS.enc.Utf8);
     } catch (error) {
       console.log("===error in decrpt fun === : ",error);
       return false
     }
   }
  </code></pre>
  
  <p>Result is string which can be converted to json.</p>
  
  <p>Swift code below.</p>
  
  <pre><code>    let encryptedString = "OdqBIN4twOxKwe1aIZhTatkzVdfvN/mfB2Arra38tF25+3efc+Kl+HABZtqiGrTIihSpfW/XHW8+31Rl+uHZB2immfB6/w8E2j5ylCV8RKrqHVMMB7BPBLyr8oTuxmYEla1J1NxywLFPyNZCI4zmkYczwVSyssd5VKWH8WaBHR5Yai6MaxugdohW40byPx6xqbhwjHN5w+dh3dJBSFbM5EhQTqPwfBA1v1UBrCXooay47keSFor/7ywjV3e2bU5JrL0o+S26UF6zoVkRP1tdGAY3TqYyrPLUHVq0nIzkmnZdQk5gFGjN0sF58WdhuqjgRAtSrbmL5biuOtmQHFmNx4sUjkF4pYvfYxrj3ze2H/6G03cxCzW/DUytV678IBrd"
  
  //======== iv &amp; cipher text should be same as generated in above javascript code ==========//
          //======== Should these keys be in hex =======//
          let iv = "" /* No idea how to get iv from encrypted string */
          let cipherText = "" /* No idea how to get cipherText from encrypted string */
          let key = "abababababababab"
  
          do {
              let decryptor = try AES(key: key, iv: iv)
              let decryptedBytes = try decryptor.decrypt(cipherText.bytes)
              print(String(bytes: decryptedBytes, encoding: .utf8)!)
          } catch {
              print(error)
          }
  </code></pre>
  
  <p>How do I get iv, key &amp; cipher text for swift similar to that in javascript?
  Thanks in advance.</p>