{"action":"created","issue":{"url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/20","labels_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/20/labels{/name}","comments_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/20/comments","events_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/20/events","html_url":"https://github.com/krzyzanowskim/CryptoSwift/issues/20","id":55865102,"number":20,"title":"Convert encrypted data to string?","user":{"login":"thehellsoul","id":7099333,"avatar_url":"https://avatars.githubusercontent.com/u/7099333?v=3","gravatar_id":"","url":"https://api.github.com/users/thehellsoul","html_url":"https://github.com/thehellsoul","followers_url":"https://api.github.com/users/thehellsoul/followers","following_url":"https://api.github.com/users/thehellsoul/following{/other_user}","gists_url":"https://api.github.com/users/thehellsoul/gists{/gist_id}","starred_url":"https://api.github.com/users/thehellsoul/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thehellsoul/subscriptions","organizations_url":"https://api.github.com/users/thehellsoul/orgs","repos_url":"https://api.github.com/users/thehellsoul/repos","events_url":"https://api.github.com/users/thehellsoul/events{/privacy}","received_events_url":"https://api.github.com/users/thehellsoul/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/labels/invalid","name":"invalid","color":"e6e6e6"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":15,"created_at":"2015-01-29T07:13:12Z","updated_at":"2015-02-01T21:45:25Z","closed_at":"2015-01-29T11:12:25Z","body":"I need to send encrypted data as string to server.\r\nI tried : \r\nlet encryptedString = NSString(data: encryptedData, encoding: NSUTF8StringEncoding)\r\n println(encryptedString)\r\nbut the result is **nil**\r\nSo can you add a function to convert encrypted data to string?"},"comment":{"url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/comments/72386058","html_url":"https://github.com/krzyzanowskim/CryptoSwift/issues/20#issuecomment-72386058","issue_url":"https://api.github.com/repos/krzyzanowskim/CryptoSwift/issues/20","id":72386058,"user":{"login":"krzyzanowskim","id":758033,"avatar_url":"https://avatars.githubusercontent.com/u/758033?v=3","gravatar_id":"","url":"https://api.github.com/users/krzyzanowskim","html_url":"https://github.com/krzyzanowskim","followers_url":"https://api.github.com/users/krzyzanowskim/followers","following_url":"https://api.github.com/users/krzyzanowskim/following{/other_user}","gists_url":"https://api.github.com/users/krzyzanowskim/gists{/gist_id}","starred_url":"https://api.github.com/users/krzyzanowskim/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krzyzanowskim/subscriptions","organizations_url":"https://api.github.com/users/krzyzanowskim/orgs","repos_url":"https://api.github.com/users/krzyzanowskim/repos","events_url":"https://api.github.com/users/krzyzanowskim/events{/privacy}","received_events_url":"https://api.github.com/users/krzyzanowskim/received_events","type":"User","site_admin":false},"created_at":"2015-02-01T21:45:25Z","updated_at":"2015-02-01T21:45:25Z","body":"it is, just php encrypt() is doing much more, is calculating MAC, creating JSON, combine IV and cipher result, then this all is encoded with base64\r\n\r\n```\r\n\tpublic function encrypt($value)\r\n\t{\r\n\t\t$iv = mcrypt_create_iv($this->getIvSize(), $this->getRandomizer());\r\n\t\t$value = base64_encode($this->padAndMcrypt($value, $iv));\r\n\t\t// Once we have the encrypted value we will go ahead base64_encode the input\r\n\t\t// vector and create the MAC for the encrypted value so we can verify its\r\n\t\t// authenticity. Then, we'll JSON encode the data in a \"payload\" array.\r\n\t\t$mac = $this->hash($iv = base64_encode($iv), $value);\r\n\t\treturn base64_encode(json_encode(compact('iv', 'value', 'mac')));\r\n\t}\r\n```"}}