title: Data encrypted by CryptoSwift is not same as Node.js
body: <p>I used CryptoSwift to encrypt some data, and then encrypted the same data using Node.js. But the results are not same. I asked the author, he said it's not a bug.</p>
  
  <p>I don't know where I made a mistake. Here are pictures of how I used CryptoSwift and Node.js:</p>
  
  <p>Cipher algorithm: aes-256-cfb</p>
  
  <p>key: 32 bytes 1</p>
  
  <p>iv: 16 bytes 0</p>
  
  <p>CryptoSwift: develop-branch 0.1.1</p>
  
  <p>Node.js: LTS 4.2.3 </p>
  
  <p><a href="http://i.stack.imgur.com/jFWaT.png" rel="nofollow">Data encrypted by CryptoSwift</a></p>
  
  <p><a href="http://i.stack.imgur.com/iwbhW.png" rel="nofollow">Data encrypted by Node.js 4.2.3</a></p>
  
  <p>Here is swift code: </p>
  
  <pre><code>    func testAES() {
      let key = [UInt8](count: 32, repeatedValue: 1)
      let iv = [UInt8](count: 16, repeatedValue: 0)
      print(key)
      print(iv)
  
      let aes256cfb = try! AES(key: key, iv: iv, blockMode: .CFB)
  
      let en1 = try! aes256cfb.encrypt([0x5, 0x77], padding: nil)
      print(en1.map({ i in String(format: "%2x", i)}))
  
      let en2 = try! aes256cfb.encrypt([0x5, 0x0, 0x3, 0x89, 0x20], padding: nil)
      print(en2.map({ i in String(format: "%2x", i)}))
  }
  
  CryptoSwift: 
  ["77", "ef"]
  ["77", "98", "c9", "2c", "45"]
  
  Node.js: 
  &lt;Buffer 77 ef&gt;
  &lt;Buffer cf a5 66 8a 3e&gt;
  </code></pre>
  
  <p>You can see, the first two bytes are same, but the rest are not. Why? Is my code writing wrong? I don't know much about crypto, please tell me the reason. Thank you so much.</p>