{"id":4957,"date":"2015-10-04T10:46:14","date_gmt":"2015-10-04T07:46:14","guid":{"rendered":"http:\/\/mummila.net\/kommentit\/?p=4957"},"modified":"2015-10-04T15:48:06","modified_gmt":"2015-10-04T12:48:06","slug":"my-first-quick-implementation-of-the-full-page-as-key-idea","status":"publish","type":"post","link":"https:\/\/mummila.net\/kommentit\/2015\/10\/04\/my-first-quick-implementation-of-the-full-page-as-key-idea\/","title":{"rendered":"My first quick implementation of the &#8221;full page as key&#8221; idea"},"content":{"rendered":"<p>Here&#8217;s my first quick implementation of the &#8221;full page as key&#8221; idea:<\/p>\n<p>Save page as key:<\/p>\n<pre><code>(function () {\r\n    localStorage.setItem('libraryOfBabelKey', document.getElementById('textblock').textContent);\r\n}());<\/code><\/pre>\n<p>Decrypt using previously saved key:<\/p>\n<pre><code>(function () {\r\n    var alphabet, c, i, m, text, key;\r\n\r\n    alphabet = 'abcdefghijklmnopqrstuvwxyz,. ';\r\n    key = localStorage.getItem('libraryOfBabelKey');\r\n    if (!key) {\r\n        alert('No key has been saved.');\r\n        return;\r\n    }\r\n    text = {\r\n        original: document.getElementById('textblock').textContent,\r\n        decoded: ''\r\n    };\r\n\r\n    for (i = 0; i &lt; text.original.length; i += 1) {\r\n        c = text.original.substr(i, 1);\r\n        if (c === &#039;\\n&#039;) {\r\n            text.decoded += c;\r\n        } else {\r\n            m = alphabet.indexOf(key.substr(i, 1));\r\n            text.decoded += alphabet.substr(((alphabet.indexOf(c) - m) % alphabet.length), 1);\r\n        }\r\n    }\r\n    document.getElementById(&#039;textblock&#039;).textContent = text.decoded;\r\n}());<\/code><\/pre>\n","protected":false},"excerpt":{"rendered":"<p>Here&#8217;s my first quick implementation of the &#8221;full page as key&#8221; idea: &#8221;Save page as key&#8221; and &#8221;Decrypt using previously saved key&#8221; bookmarklets.<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1097],"tags":[],"class_list":["post-4957","post","type-post","status-publish","format-standard","hentry","category-keskustelupalstat","sijainti-library-of-babel"],"_links":{"self":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/4957","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/comments?post=4957"}],"version-history":[{"count":2,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/4957\/revisions"}],"predecessor-version":[{"id":4959,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/posts\/4957\/revisions\/4959"}],"wp:attachment":[{"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/media?parent=4957"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/categories?post=4957"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mummila.net\/kommentit\/wp-json\/wp\/v2\/tags?post=4957"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}