{"action":"created","issue":{"url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/81","labels_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/81/labels{/name}","comments_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/81/comments","events_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/81/events","html_url":"https://github.com/krzyzanowskim/CryptoSwift/issues/81","id":88645012,"number":81,"title":"Array index out of range while trying to encrypt/decrypt","user":{"login":"imrielruchi","id":12607629,"avatar_url":"https://avatars.githubusercontent.com/u/12607629?v=3","gravatar_id":"","url":"https://api.github.com/users/imrielruchi","html_url":"https://github.com/imrielruchi","followers_url":"https://api.github.com/users/imrielruchi/followers","following_url":"https://api.github.com/users/imrielruchi/following{/other_user}","gists_url":"https://api.github.com/users/imrielruchi/gists{/gist_id}","starred_url":"https://api.github.com/users/imrielruchi/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/imrielruchi/subscriptions","organizations_url":"https://api.github.com/users/imrielruchi/orgs","repos_url":"https://api.github.com/users/imrielruchi/repos","events_url":"https://api.github.com/users/imrielruchi/events{/privacy}","received_events_url":"https://api.github.com/users/imrielruchi/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2015-06-16T07:29:36Z","updated_at":"2015-06-16T16:43:06Z","closed_at":null,"body":"Hi,\r\n\r\nI am trying to encrypt using AES with CryptoSwift. when i run below code it throws error \"fatal error: Array index out of range\".\r\n\r\n\r\n   let key = \"1234567890123456\" // key\r\n   let iv = \"1234567890123456\" // random\r\n   let message = \"This is test string\"\r\n\r\n    // encrypt\r\n    let encrypted = AES(key: key, iv: iv, blockMode: .CBC)\r\n    let enc =  encrypted?.encrypt(message.utf8Array, padding: PKCS7())\r\n    println(\"enc >>  \\(enc)\")\r\n\r\n    // decrypt\r\n    let decrypted = AES(key: key, iv: iv, blockMode: .CBC)\r\n    let dec =  encrypted?.decrypt(enc!, padding: PKCS7())\r\n    println(\"dec >>  \\(dec)\")"},"comment":{"url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/comments/112493598","html_url":"https://github.com/krzyzanowskim/CryptoSwift/issues/81#issuecomment-112493598","issue_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/81","id":112493598,"user":{"login":"archie","id":86441,"avatar_url":"https://avatars.githubusercontent.com/u/86441?v=3","gravatar_id":"","url":"https://api.github.com/users/archie","html_url":"https://github.com/archie","followers_url":"https://api.github.com/users/archie/followers","following_url":"https://api.github.com/users/archie/following{/other_user}","gists_url":"https://api.github.com/users/archie/gists{/gist_id}","starred_url":"https://api.github.com/users/archie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/archie/subscriptions","organizations_url":"https://api.github.com/users/archie/orgs","repos_url":"https://api.github.com/users/archie/repos","events_url":"https://api.github.com/users/archie/events{/privacy}","received_events_url":"https://api.github.com/users/archie/received_events","type":"User","site_admin":false},"created_at":"2015-06-16T16:43:05Z","updated_at":"2015-06-16T16:43:05Z","body":"We've run into the same problem. \r\n\r\nFrom the [Swift documentation](https://developer.apple.com/library/ios/documentation/Swift/Conceptual/Swift_Programming_Language/Enumerations.html)\r\n\r\n> Unlike C and Objective-C, Swift enumeration members are not assigned a default integer value when they are created. In the CompassPoint example above, North, South, East and West do not implicitly equal 0, 1, 2 and 3. Instead, the different enumeration members are fully-fledged values in their own right, with an explicitly-defined type of CompassPoint.\r\n\r\nWe're suggesting the following patch to force the enumeration start at 1: \r\n\r\n```\r\ndiff --git a/CryptoSwift/AES.swift b/CryptoSwift/AES.swift\r\nindex d8665af..7f052e8 100644\r\n--- a/CryptoSwift/AES.swift\r\n+++ b/CryptoSwift/AES.swift\r\n@@ -11,7 +11,7 @@ import Foundation\r\n final public class AES {\r\n\r\n     public enum AESVariant:Int {\r\n-        case aes128, aes192, aes256\r\n+        case aes128 = 1, aes192, aes256\r\n\r\n         var Nk:Int { // Nk words\r\n             return [4,6,8][self.rawValue - 1]\r\n```"}}