{"action":"created","comment":{"url":"https://api.github.com/repos/nagado/educ/pulls/comments/37882111","id":37882111,"diff_hunk":"@@ -0,0 +1,177 @@\n+#include <iostream>\n+#include <string>\n+#include <fstream>\n+#include <ios>\n+#include <random>\n+#include <sstream>\n+#include <utility>\n+#include <iterator>\n+\n+using Byte = char;\n+\n+//=====put_error=====//\n+void put_error(const std::string& error_message)\n+{\n+  std::cout << error_message;\n+  exit(1);\n+}\n+\n+//=====shuffle=====//\n+void shuffle(std::vector<Byte>& input)\n+{\n+  std::default_random_engine gen;\n+\n+  for (size_t i = 0; i < input.size(); ++i)\n+  {\n+    std::uniform_int_distribution<int> dis (i, input.size() - 1);\n+    std::swap(input[i], input[dis(gen)]);\n+  } \n+}\n+\n+//=====write_file=====//\n+void write_file(const std::string& filename, std::vector<Byte> output, const std::string error_message)\n+{\n+  std::ofstream file (filename, std::ios::out|std::ios::binary|std::ios::trunc);\n+  if (!file.is_open())\n+    put_error(error_message);\n+  \n+  file.write(&output[0], output.size());\n+}\n+\n+//=====make_key=====//\n+void make_key(const std::string& filename)\n+{\n+  std::vector<Byte> input;\n+  std::ifstream file (filename);\n+  input.assign(std::istream_iterator<char>(file), std::istream_iterator<char>());\n+  shuffle(input);\n+  std::string keyname = filename + \".key\";\n+  write_file(keyname, input, \"Couldn't open file to save the result.\\n\");\n+}\n+\n+//=====read_key_position=====//\n+std::streampos read_key_position(const std::string keyname)\n+{\n+  long tmp = 0;","path":"encrypter.cpp","position":55,"original_position":55,"commit_id":"b4afa978639f5565277217d153bcee40c0d5cd28","original_commit_id":"b4afa978639f5565277217d153bcee40c0d5cd28","user":{"login":"dlazarus","id":6580913,"avatar_url":"https://avatars.githubusercontent.com/u/6580913?v=3","gravatar_id":"","url":"https://api.github.com/users/dlazarus","html_url":"https://github.com/dlazarus","followers_url":"https://api.github.com/users/dlazarus/followers","following_url":"https://api.github.com/users/dlazarus/following{/other_user}","gists_url":"https://api.github.com/users/dlazarus/gists{/gist_id}","starred_url":"https://api.github.com/users/dlazarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlazarus/subscriptions","organizations_url":"https://api.github.com/users/dlazarus/orgs","repos_url":"https://api.github.com/users/dlazarus/repos","events_url":"https://api.github.com/users/dlazarus/events{/privacy}","received_events_url":"https://api.github.com/users/dlazarus/received_events","type":"User","site_admin":false},"body":"rename tmp -> pos. This variable has pretty clear purpose","created_at":"2015-08-25T15:50:50Z","updated_at":"2015-08-25T15:50:50Z","html_url":"https://github.com/nagado/educ/pull/1#discussion_r37882111","pull_request_url":"https://api.github.com/repos/nagado/educ/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/nagado/educ/pulls/comments/37882111"},"html":{"href":"https://github.com/nagado/educ/pull/1#discussion_r37882111"},"pull_request":{"href":"https://api.github.com/repos/nagado/educ/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/nagado/educ/pulls/1","id":42355184,"html_url":"https://github.com/nagado/educ/pull/1","diff_url":"https://github.com/nagado/educ/pull/1.diff","patch_url":"https://github.com/nagado/educ/pull/1.patch","issue_url":"https://api.github.com/repos/nagado/educ/issues/1","number":1,"state":"open","locked":false,"title":"first version of encrypter","user":{"login":"dlazarus","id":6580913,"avatar_url":"https://avatars.githubusercontent.com/u/6580913?v=3","gravatar_id":"","url":"https://api.github.com/users/dlazarus","html_url":"https://github.com/dlazarus","followers_url":"https://api.github.com/users/dlazarus/followers","following_url":"https://api.github.com/users/dlazarus/following{/other_user}","gists_url":"https://api.github.com/users/dlazarus/gists{/gist_id}","starred_url":"https://api.github.com/users/dlazarus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlazarus/subscriptions","organizations_url":"https://api.github.com/users/dlazarus/orgs","repos_url":"https://api.github.com/users/dlazarus/repos","events_url":"https://api.github.com/users/dlazarus/events{/privacy}","received_events_url":"https://api.github.com/users/dlazarus/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-08-13T14:16:19Z","updated_at":"2015-08-25T15:50:50Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4e31e37e2d8d22b995ba4682a8ebb73293c26117","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/nagado/educ/pulls/1/commits","review_comments_url":"https://api.github.com/repos/nagado/educ/pulls/1/comments","review_comment_url":"https://api.github.com/repos/nagado/educ/pulls/comments{/number}","comments_url":"https://api.github.com/repos/nagado/educ/issues/1/comments","statuses_url":"https://api.github.com/repos/nagado/educ/statuses/b4afa978639f5565277217d153bcee40c0d5cd28","head":{"label":"nagado:encrypter","ref":"encrypter","sha":"b4afa978639f5565277217d153bcee40c0d5cd28","user":{"login":"nagado","id":6580926,"avatar_url":"https://avatars.githubusercontent.com/u/6580926?v=3","gravatar_id":"","url":"https://api.github.com/users/nagado","html_url":"https://github.com/nagado","followers_url":"https://api.github.com/users/nagado/followers","following_url":"https://api.github.com/users/nagado/following{/other_user}","gists_url":"https://api.github.com/users/nagado/gists{/gist_id}","starred_url":"https://api.github.com/users/nagado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagado/subscriptions","organizations_url":"https://api.github.com/users/nagado/orgs","repos_url":"https://api.github.com/users/nagado/repos","events_url":"https://api.github.com/users/nagado/events{/privacy}","received_events_url":"https://api.github.com/users/nagado/received_events","type":"User","site_admin":false},"repo":{"id":40633521,"name":"educ","full_name":"nagado/educ","owner":{"login":"nagado","id":6580926,"avatar_url":"https://avatars.githubusercontent.com/u/6580926?v=3","gravatar_id":"","url":"https://api.github.com/users/nagado","html_url":"https://github.com/nagado","followers_url":"https://api.github.com/users/nagado/followers","following_url":"https://api.github.com/users/nagado/following{/other_user}","gists_url":"https://api.github.com/users/nagado/gists{/gist_id}","starred_url":"https://api.github.com/users/nagado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagado/subscriptions","organizations_url":"https://api.github.com/users/nagado/orgs","repos_url":"https://api.github.com/users/nagado/repos","events_url":"https://api.github.com/users/nagado/events{/privacy}","received_events_url":"https://api.github.com/users/nagado/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nagado/educ","description":"","fork":false,"url":"https://api.github.com/repos/nagado/educ","forks_url":"https://api.github.com/repos/nagado/educ/forks","keys_url":"https://api.github.com/repos/nagado/educ/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nagado/educ/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nagado/educ/teams","hooks_url":"https://api.github.com/repos/nagado/educ/hooks","issue_events_url":"https://api.github.com/repos/nagado/educ/issues/events{/number}","events_url":"https://api.github.com/repos/nagado/educ/events","assignees_url":"https://api.github.com/repos/nagado/educ/assignees{/user}","branches_url":"https://api.github.com/repos/nagado/educ/branches{/branch}","tags_url":"https://api.github.com/repos/nagado/educ/tags","blobs_url":"https://api.github.com/repos/nagado/educ/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nagado/educ/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nagado/educ/git/refs{/sha}","trees_url":"https://api.github.com/repos/nagado/educ/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nagado/educ/statuses/{sha}","languages_url":"https://api.github.com/repos/nagado/educ/languages","stargazers_url":"https://api.github.com/repos/nagado/educ/stargazers","contributors_url":"https://api.github.com/repos/nagado/educ/contributors","subscribers_url":"https://api.github.com/repos/nagado/educ/subscribers","subscription_url":"https://api.github.com/repos/nagado/educ/subscription","commits_url":"https://api.github.com/repos/nagado/educ/commits{/sha}","git_commits_url":"https://api.github.com/repos/nagado/educ/git/commits{/sha}","comments_url":"https://api.github.com/repos/nagado/educ/comments{/number}","issue_comment_url":"https://api.github.com/repos/nagado/educ/issues/comments{/number}","contents_url":"https://api.github.com/repos/nagado/educ/contents/{+path}","compare_url":"https://api.github.com/repos/nagado/educ/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nagado/educ/merges","archive_url":"https://api.github.com/repos/nagado/educ/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nagado/educ/downloads","issues_url":"https://api.github.com/repos/nagado/educ/issues{/number}","pulls_url":"https://api.github.com/repos/nagado/educ/pulls{/number}","milestones_url":"https://api.github.com/repos/nagado/educ/milestones{/number}","notifications_url":"https://api.github.com/repos/nagado/educ/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nagado/educ/labels{/name}","releases_url":"https://api.github.com/repos/nagado/educ/releases{/id}","created_at":"2015-08-13T01:52:34Z","updated_at":"2015-08-13T01:52:34Z","pushed_at":"2015-08-22T00:46:52Z","git_url":"git://github.com/nagado/educ.git","ssh_url":"git@github.com:nagado/educ.git","clone_url":"https://github.com/nagado/educ.git","svn_url":"https://github.com/nagado/educ","homepage":null,"size":140,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"base":{"label":"nagado:master","ref":"master","sha":"d8368f5339e468bf25406041bbff90aee8873dc9","user":{"login":"nagado","id":6580926,"avatar_url":"https://avatars.githubusercontent.com/u/6580926?v=3","gravatar_id":"","url":"https://api.github.com/users/nagado","html_url":"https://github.com/nagado","followers_url":"https://api.github.com/users/nagado/followers","following_url":"https://api.github.com/users/nagado/following{/other_user}","gists_url":"https://api.github.com/users/nagado/gists{/gist_id}","starred_url":"https://api.github.com/users/nagado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagado/subscriptions","organizations_url":"https://api.github.com/users/nagado/orgs","repos_url":"https://api.github.com/users/nagado/repos","events_url":"https://api.github.com/users/nagado/events{/privacy}","received_events_url":"https://api.github.com/users/nagado/received_events","type":"User","site_admin":false},"repo":{"id":40633521,"name":"educ","full_name":"nagado/educ","owner":{"login":"nagado","id":6580926,"avatar_url":"https://avatars.githubusercontent.com/u/6580926?v=3","gravatar_id":"","url":"https://api.github.com/users/nagado","html_url":"https://github.com/nagado","followers_url":"https://api.github.com/users/nagado/followers","following_url":"https://api.github.com/users/nagado/following{/other_user}","gists_url":"https://api.github.com/users/nagado/gists{/gist_id}","starred_url":"https://api.github.com/users/nagado/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nagado/subscriptions","organizations_url":"https://api.github.com/users/nagado/orgs","repos_url":"https://api.github.com/users/nagado/repos","events_url":"https://api.github.com/users/nagado/events{/privacy}","received_events_url":"https://api.github.com/users/nagado/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/nagado/educ","description":"","fork":false,"url":"https://api.github.com/repos/nagado/educ","forks_url":"https://api.github.com/repos/nagado/educ/forks","keys_url":"https://api.github.com/repos/nagado/educ/keys{/key_id}","collaborators_url":"https://api.github.com/repos/nagado/educ/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/nagado/educ/teams","hooks_url":"https://api.github.com/repos/nagado/educ/hooks","issue_events_url":"https://api.github.com/repos/nagado/educ/issues/events{/number}","events_url":"https://api.github.com/repos/nagado/educ/events","assignees_url":"https://api.github.com/repos/nagado/educ/assignees{/user}","branches_url":"https://api.github.com/repos/nagado/educ/branches{/branch}","tags_url":"https://api.github.com/repos/nagado/educ/tags","blobs_url":"https://api.github.com/repos/nagado/educ/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/nagado/educ/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/nagado/educ/git/refs{/sha}","trees_url":"https://api.github.com/repos/nagado/educ/git/trees{/sha}","statuses_url":"https://api.github.com/repos/nagado/educ/statuses/{sha}","languages_url":"https://api.github.com/repos/nagado/educ/languages","stargazers_url":"https://api.github.com/repos/nagado/educ/stargazers","contributors_url":"https://api.github.com/repos/nagado/educ/contributors","subscribers_url":"https://api.github.com/repos/nagado/educ/subscribers","subscription_url":"https://api.github.com/repos/nagado/educ/subscription","commits_url":"https://api.github.com/repos/nagado/educ/commits{/sha}","git_commits_url":"https://api.github.com/repos/nagado/educ/git/commits{/sha}","comments_url":"https://api.github.com/repos/nagado/educ/comments{/number}","issue_comment_url":"https://api.github.com/repos/nagado/educ/issues/comments{/number}","contents_url":"https://api.github.com/repos/nagado/educ/contents/{+path}","compare_url":"https://api.github.com/repos/nagado/educ/compare/{base}...{head}","merges_url":"https://api.github.com/repos/nagado/educ/merges","archive_url":"https://api.github.com/repos/nagado/educ/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/nagado/educ/downloads","issues_url":"https://api.github.com/repos/nagado/educ/issues{/number}","pulls_url":"https://api.github.com/repos/nagado/educ/pulls{/number}","milestones_url":"https://api.github.com/repos/nagado/educ/milestones{/number}","notifications_url":"https://api.github.com/repos/nagado/educ/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/nagado/educ/labels{/name}","releases_url":"https://api.github.com/repos/nagado/educ/releases{/id}","created_at":"2015-08-13T01:52:34Z","updated_at":"2015-08-13T01:52:34Z","pushed_at":"2015-08-22T00:46:52Z","git_url":"git://github.com/nagado/educ.git","ssh_url":"git@github.com:nagado/educ.git","clone_url":"https://github.com/nagado/educ.git","svn_url":"https://github.com/nagado/educ","homepage":null,"size":140,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/nagado/educ/pulls/1"},"html":{"href":"https://github.com/nagado/educ/pull/1"},"issue":{"href":"https://api.github.com/repos/nagado/educ/issues/1"},"comments":{"href":"https://api.github.com/repos/nagado/educ/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/nagado/educ/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/nagado/educ/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/nagado/educ/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/nagado/educ/statuses/b4afa978639f5565277217d153bcee40c0d5cd28"}}}}