{"action":"created","issue":{"url":"https://api.github.com/repos/crypto-browserify/browserify-aes/issues/26","labels_url":"https://api.github.com/repos/crypto-browserify/browserify-aes/issues/26/labels{/name}","comments_url":"https://api.github.com/repos/crypto-browserify/browserify-aes/issues/26/comments","events_url":"https://api.github.com/repos/crypto-browserify/browserify-aes/issues/26/events","html_url":"https://github.com/crypto-browserify/browserify-aes/issues/26","id":107889937,"number":26,"title":"Long utf8 plaintexts get corrupted when decrypting.","user":{"login":"dabura667","id":6586275,"avatar_url":"https://avatars.githubusercontent.com/u/6586275?v=3","gravatar_id":"","url":"https://api.github.com/users/dabura667","html_url":"https://github.com/dabura667","followers_url":"https://api.github.com/users/dabura667/followers","following_url":"https://api.github.com/users/dabura667/following{/other_user}","gists_url":"https://api.github.com/users/dabura667/gists{/gist_id}","starred_url":"https://api.github.com/users/dabura667/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dabura667/subscriptions","organizations_url":"https://api.github.com/users/dabura667/orgs","repos_url":"https://api.github.com/users/dabura667/repos","events_url":"https://api.github.com/users/dabura667/events{/privacy}","received_events_url":"https://api.github.com/users/dabura667/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2015-09-23T10:24:17Z","updated_at":"2015-09-23T13:04:57Z","closed_at":null,"body":"Here's the functions I wrote.\r\n```javascript\r\nvar Crypto = require('crypto-browserify');\r\n\r\nvar encrypt = function (txt, passwd, salt) {\r\n  salt = salt || \"テストです。この塩を変えた方が安全です。\";\r\n  var cipher = Crypto.createCipher('aes-256-cbc',Crypto.pbkdf2Sync(passwd, salt, 8192, 32, 'sha256'));\r\n  var result = cipher.update(txt, 'utf8', 'base64')\r\n  result += cipher.final('base64')\r\n  cipher = null;\r\n  txt = null;\r\n  passwd = null;\r\n  salt = null;\r\n  return result;\r\n};\r\nvar decrypt = function (enc, passwd, salt) {\r\n  salt = salt || \"テストです。この塩を変えた方が安全です。\";\r\n  var decipher = Crypto.createDecipher('aes-256-cbc',Crypto.pbkdf2Sync(passwd, salt, 8192, 32, 'sha256'));\r\n  try {\r\n    var result = decipher.update(enc, 'base64', 'utf8')\r\n    result += decipher.final('utf8')\r\n  } catch(e) {\r\n    return null;\r\n  };\r\n  decipher = null;\r\n  enc = null;\r\n  passwd = null;\r\n  salt = null;\r\n  return result;\r\n};\r\n\r\nvar enc = encrypt(\"ふっかつ　あきる　すぶり　はやい　つける　まゆげ　たんさん　みんぞく　ねほりはほり　せまい　たいまつばな　ひはん\",\"a\",\"a\");\r\n// gives me \"95XLoYZrLtCzx/WDzQ+G5vA293ynWpBhNRyIUV2CTZACSR4HKwWCAIIUklewk/bmTeFvzk7X0yRAQVXnkgwgMfAVs5uDkw6naSWN5akWwLYbEZurjFaQcdncy9wvmmS2c8gOFo90yWNSrQRKlhifmi5ibgVF3HgvDTcksofTjUzzFxaRqINZuHjcVZMiggAAX1etUgZdSM8O33ciWwyv2YBo2EsJOb9z1KyMNXaICK2PtC505Sru9W9q1mnPQOAA\"\r\n\r\nvar dec = decrypt(enc, \"a\", \"a\");\r\n// gives me \"��\" (which is two utf8 characters of \"\\uFFFD\")\r\n```\r\n\r\nIf you could:\r\na. tell me if my functions are written wrong, if that's the case.\r\nb. fix the problem if it is a problem with the library.\r\n\r\nI would greatly appreciate it. Thanks.\r\n\r\nbtw, if I just encrypt a short string like ふっかつ and decrypt it it comes out fine.\r\n\r\nAlso: The text I am trying above is 60 utf8 3 byte characters, but I tried 180 \"a\"s together and it decrypted fine. I think it's a problem with the base64 >> utf8 conversion or something."},"comment":{"url":"https://api.github.com/repos/crypto-browserify/browserify-aes/issues/comments/142592766","html_url":"https://github.com/crypto-browserify/browserify-aes/issues/26#issuecomment-142592766","issue_url":"https://api.github.com/repos/crypto-browserify/browserify-aes/issues/26","id":142592766,"user":{"login":"calvinmetcalf","id":1128607,"avatar_url":"https://avatars.githubusercontent.com/u/1128607?v=3","gravatar_id":"","url":"https://api.github.com/users/calvinmetcalf","html_url":"https://github.com/calvinmetcalf","followers_url":"https://api.github.com/users/calvinmetcalf/followers","following_url":"https://api.github.com/users/calvinmetcalf/following{/other_user}","gists_url":"https://api.github.com/users/calvinmetcalf/gists{/gist_id}","starred_url":"https://api.github.com/users/calvinmetcalf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/calvinmetcalf/subscriptions","organizations_url":"https://api.github.com/users/calvinmetcalf/orgs","repos_url":"https://api.github.com/users/calvinmetcalf/repos","events_url":"https://api.github.com/users/calvinmetcalf/events{/privacy}","received_events_url":"https://api.github.com/users/calvinmetcalf/received_events","type":"User","site_admin":false},"created_at":"2015-09-23T13:04:57Z","updated_at":"2015-09-23T13:04:57Z","body":"see #27"}}