{"action":"created","issue":{"url":"https://api.github.com/repos/jedisct1/libsodium-php/issues/33","labels_url":"https://api.github.com/repos/jedisct1/libsodium-php/issues/33/labels{/name}","comments_url":"https://api.github.com/repos/jedisct1/libsodium-php/issues/33/comments","events_url":"https://api.github.com/repos/jedisct1/libsodium-php/issues/33/events","html_url":"https://github.com/jedisct1/libsodium-php/issues/33","id":89876550,"number":33,"title":"Automatically append nonce / IV to ciphertext","user":{"login":"leonklingele","id":5585491,"avatar_url":"https://avatars.githubusercontent.com/u/5585491?v=3","gravatar_id":"","url":"https://api.github.com/users/leonklingele","html_url":"https://github.com/leonklingele","followers_url":"https://api.github.com/users/leonklingele/followers","following_url":"https://api.github.com/users/leonklingele/following{/other_user}","gists_url":"https://api.github.com/users/leonklingele/gists{/gist_id}","starred_url":"https://api.github.com/users/leonklingele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonklingele/subscriptions","organizations_url":"https://api.github.com/users/leonklingele/orgs","repos_url":"https://api.github.com/users/leonklingele/repos","events_url":"https://api.github.com/users/leonklingele/events{/privacy}","received_events_url":"https://api.github.com/users/leonklingele/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-06-21T07:19:41Z","updated_at":"2015-06-21T07:34:53Z","closed_at":null,"body":"From readme:\r\n```php\r\n$nonce = Sodium::randombytes_buf(Sodium::CRYPTO_SECRETBOX_NONCEBYTES);\r\n$key = [a binary string that must be CRYPTO_SECRETBOX_KEYBYTES long];\r\n$ciphertext = Sodium::crypto_secretbox('test', $nonce, $key);\r\n$plaintext = Sodium::crypto_secretbox_open($ciphertext, $nonce, $key);\r\n```\r\nIsn't it the purpose of a library like libsodium to make a programmer's life as easy as possible?\r\nA high level programmer (especially when dealing with crypto stuff) should avoid using nonces at all costs (i.e. pre-/appending them to the ciphertext and later substringing them out).\r\nAs the nonce is public, it can automatically be appended to the ciphertext.\r\n\r\nThere should be a wrapper function (e.g. `Sodium::crypto_secretbox_auto`) which accepts only `DATA_TO_ENCRYPT` and a `KEY`.\r\nIt should return the ciphertext including the nonce.\r\n\r\n`Sodium::crypto_secretbox_open_auto` on the other hand only accepts `DATA_TO_DECRYPT` (which has the nonce in it) and the `KEY`.\r\nIt should extract the nonce, then call and return `Sodium::crypto_secretbox_open`\r\n\r\n__`Sodium::crypto_secretbox` was only used as an example. There should be wrapper functions for all functions which accept a nonce / IV / ..__"},"comment":{"url":"https://api.github.com/repos/jedisct1/libsodium-php/issues/comments/113870993","html_url":"https://github.com/jedisct1/libsodium-php/issues/33#issuecomment-113870993","issue_url":"https://api.github.com/repos/jedisct1/libsodium-php/issues/33","id":113870993,"user":{"login":"leonklingele","id":5585491,"avatar_url":"https://avatars.githubusercontent.com/u/5585491?v=3","gravatar_id":"","url":"https://api.github.com/users/leonklingele","html_url":"https://github.com/leonklingele","followers_url":"https://api.github.com/users/leonklingele/followers","following_url":"https://api.github.com/users/leonklingele/following{/other_user}","gists_url":"https://api.github.com/users/leonklingele/gists{/gist_id}","starred_url":"https://api.github.com/users/leonklingele/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/leonklingele/subscriptions","organizations_url":"https://api.github.com/users/leonklingele/orgs","repos_url":"https://api.github.com/users/leonklingele/repos","events_url":"https://api.github.com/users/leonklingele/events{/privacy}","received_events_url":"https://api.github.com/users/leonklingele/received_events","type":"User","site_admin":false},"created_at":"2015-06-21T07:34:53Z","updated_at":"2015-06-21T07:34:53Z","body":"Too late :sleepy:. Seems to be related to #31 "}}