{"id":283418,"date":"2017-01-05T14:35:03","date_gmt":"2017-01-05T11:35:03","guid":{"rendered":"http:\/\/savepearlharbor.com\/?p=283418"},"modified":"-0001-11-30T00:00:00","modified_gmt":"-0001-11-29T21:00:00","slug":"","status":"publish","type":"post","link":"https:\/\/savepearlharbor.com\/?p=283418","title":{"rendered":"end-to-end \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432 dropbox"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cee\/269\/4b1\/cee2694b1733421fac89e20b3dbdacb5.jpg\" alt=\"image\"\/><\/p>\n<p>\u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0442\u0430\u0439\u043d\u044b \u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0447\u043d\u043e \u043f\u044b\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0443\u0442\u0438 \u043a\u0430\u043a \u0438\u0445 \u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u0430\u043a \u0438 \u0440\u0430\u0437\u043e\u0431\u043b\u0430\u0447\u0435\u043d\u0438\u044f.<br \/>  \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u043a\u0440\u044b\u0442\u044c \u0441\u0432\u043e\u0438 \u0444\u0430\u0439\u043b\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448 \u043f\u0430\u0440\u0430\u043d\u043e\u0438\u043a \u0431\u044b\u043b \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432<\/p>\n<p><a name=\"habracut\"><\/a>  <\/p>\n<p>\u041d\u0435 \u043c\u043e\u0433\u0443 \u0441\u043a\u0430\u0437\u0430\u0442\u044c, \u0447\u0442\u043e \u044f \u043f\u0430\u0440\u0430\u043d\u043e\u0438\u043a \u0434\u043e \u043c\u043e\u0437\u0433\u0430 \u043a\u043e\u0441\u0442\u0435\u0439, \u043d\u043e \u0431\u044b\u0432\u0430\u044e\u0442 \u0441\u043b\u0443\u0447\u0430\u0438 \u043a\u043e\u0433\u0434\u0430 \u043c\u043d\u0435 \u043d\u0443\u0436\u043d\u043e \u0431\u044b\u0442\u044c \u0443\u0432\u0435\u0440\u0435\u043d\u043d\u044b\u043c, \u0447\u0442\u043e \u0438\u043d\u0444\u043e\u0440\u043c\u0430\u0446\u0438\u044f \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u043a\u0443\u0434\u0430 \u043d\u0435 \u043d\u0430\u0434\u043e, \u043d\u043e \u043f\u0440\u0438 \u044d\u0442\u043e\u043c \u0438 \u043d\u0435 \u043f\u043e\u0442\u0435\u0440\u044f\u0435\u0442\u0441\u044f.<\/p>\n<p>  <\/p>\n<p>\u0425\u043e\u0447\u0443 \u0437\u0430\u043c\u0435\u0442\u0438\u0442\u044c, \u0447\u0442\u043e \u044f \u043d\u0435 \u043f\u0440\u0435\u0442\u0435\u043d\u0434\u0443\u044e \u043d\u0430 \u0437\u0432\u0430\u043d\u0438\u0435 &quot;\u0443\u043d\u0438\u043a\u0430\u043b\u044c\u043d\u044b\u0439 \u043f\u0440\u043e\u0435\u043a\u0442&quot;, \u0435\u0441\u0442\u044c 100500 \u043f\u043e\u0445\u043e\u0436\u0438\u0445 \u043f\u0440\u043e\u0435\u043a\u0442\u043e\u0432 \u0441\u043e \u0441\u0432\u043e\u0438\u043c\u0438 \u043f\u043b\u044e\u0441\u0430\u043c\u0438 \u0438 \u043c\u0438\u043d\u0443\u0441\u0430\u043c\u0438.<\/p>\n<p>  <\/p>\n<h3>\u041a\u0440\u0430\u0442\u043a\u043e\u0435 \u043e\u043f\u0438\u0441\u0430\u043d\u0438\u0435<\/h3>\n<p>  <\/p>\n<p>\u041a\u0430\u043a \u0432\u0438\u0434\u043d\u043e \u0438\u0437 \u043d\u0430\u0437\u0432\u0430\u043d\u0438\u044f, dropcryptbox \u0440\u0430\u0431\u043e\u0442\u0430\u0435\u0442 \u043f\u043e\u0432\u0435\u0440\u0445 dropbox \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u044f oauth. \u0412\u0441\u0435 \u043e\u043f\u0435\u0440\u0430\u0446\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u044f\u0442 \u0438\u0441\u043a\u043b\u044e\u0447\u0438\u0442\u0435\u043b\u044c\u043d\u043e \u043c\u0435\u0436\u0434\u0443 \u043c\u0430\u0448\u0438\u043d\u043e\u0439 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0438 api \u0434\u0440\u043e\u043f\u0431\u043e\u043a\u0441\u0430 \u043c\u0438\u043d\u0443\u044f \u0442\u0440\u0435\u0442\u044c\u0438\u0445 \u043f\u043e\u0441\u0440\u0435\u0434\u043d\u0438\u043a\u043e\u0432, \u0430 \u044d\u0442\u043e \u0437\u043d\u0430\u0447\u0438\u0442, \u0447\u0442\u043e \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0435 \u043d\u0435 \u0438\u043c\u0435\u0435\u0442 \u0441\u0432\u043e\u0435\u0433\u043e \u0431\u0435\u043a\u0435\u043d\u0434\u0430.<\/p>\n<p>  <\/p>\n<p>\u0424\u0430\u0439\u043b\u044b \u0448\u0438\u0444\u0440\u0443\u044e\u0442\u0441\u044f \u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u044b\u0432\u0430\u044e\u0442\u0441\u044f \u043d\u0430 \u043c\u0430\u0448\u0438\u043d\u0435 \u043f\u043e\u043b\u044c\u0437\u043e\u0432\u0430\u0442\u0435\u043b\u044f \u0442\u0435\u043c \u0441\u0430\u043c\u044b\u043c \u0433\u0430\u0440\u0430\u043d\u0442\u0438\u0440\u0443\u044f, \u0447\u0442\u043e \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b\u044c\u043d\u044b\u0439 \u0444\u0430\u0439\u043b \u043d\u0435 \u043f\u043e\u043f\u0430\u0434\u0435\u0442 \u043d\u0430 \u043a\u0430\u043a\u0438\u0435-\u043b\u0438\u0431\u043e \u0441\u0435\u0440\u0432\u0435\u0440\u0430.<\/p>\n<p>  <\/p>\n<h3>\u0413\u0435\u043d\u0435\u0440\u0430\u0446\u0438\u044f \u043a\u043b\u044e\u0447\u0430<\/h3>\n<p>  <\/p>\n<p>\u041a\u043b\u044e\u0447 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0441\u043e\u0437\u0434\u0430\u0435\u0442\u0441\u044f \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043c\u0430\u0441\u0442\u0435\u0440 \u043f\u0430\u0440\u043e\u043b\u044f \u043a\u043e\u0442\u043e\u0440\u044b\u0439 \u043d\u0443\u0436\u043d\u043e \u0432\u0432\u0435\u0441\u0442\u0438 \u043f\u0440\u0438 \u043e\u0442\u043a\u0440\u044b\u0442\u0438\u0438 \u0441\u0442\u0440\u0430\u043d\u0438\u0446\u044b.<br \/>  \u0414\u043b\u044f \u043d\u0430\u0447\u0430\u043b\u0430 \u043f\u043e\u043b\u0443\u0447\u0430\u0435\u043c sha256 \u0445\u0435\u0448 \u043e\u0442 masterPassword, \u0437\u0430\u0442\u0435\u043c \u0433\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u043c pbkdf2 \u043a\u043b\u044e\u0447 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u0445\u0435\u0448\u0430(sha256), pbkdf2 (HMAC-SHA1, 256 \u0431\u0438\u0442, 1000 \u0438\u0442\u0435\u0440\u0430\u0446\u0438\u0439)<\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import sha256 from &quot;crypto-js\/sha256&quot;; import pbkdf2 from &quot;crypto-js\/pbkdf2&quot;; import HEX_ENCODING from &quot;crypto-js\/enc-hex&quot;;  export const PBKDF2 = pbkdf2; export const SHA256 = sha256;  export const salt = SHA256(&quot;CRYPTODROPBOX_SOME_SALT&quot;);  export function getKey(str){     let hash = PBKDF2(SHA256(str), salt, { keySize: 256\/32, iterations: 1000 });     return new Buffer(hash.toString(HEX_ENCODING), 'hex'); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0444\u0430\u0439\u043b\u043e\u0432<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f \u0444\u0430\u0439\u043b\u043e\u0432 \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f chacha20.<\/p>\n<p>  <\/p>\n<p>\u0412\u0441\u0451 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0432 \u043f\u0440\u0438\u043b\u043e\u0436\u0435\u043d\u0438\u0438 \u043f\u0440\u043e\u0438\u0441\u0445\u043e\u0434\u0438\u0442 \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443:<\/p>\n<p>  <\/p>\n<ul>\n<li>\u0413\u0435\u043d\u0435\u0440\u0438\u0440\u0443\u0435\u0442\u0441\u044f \u0440\u0430\u043d\u0434\u043e\u043c\u043d\u044b\u0439 nonce<\/li>\n<li>\u0428\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u043d\u0430 \u043e\u0441\u043d\u043e\u0432\u0435 \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u043d\u043e\u0433\u043e \u043a\u043b\u044e\u0447\u0430(\u043e\u0442 \u043c\u0430\u0441\u0442\u0435\u0440 \u043f\u0430\u0440\u043e\u043b\u044f)<\/li>\n<li>nonce \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u0432 \u043d\u0430\u0447\u0430\u043b\u043e \u0448\u0438\u0444\u0440\u043e\u0442\u0435\u043a\u0441\u0442\u0430<\/li>\n<\/ul>\n<p>  <\/p>\n<p>\u0418\u043c\u044f \u0444\u0430\u0439\u043b\u0430 \u0442\u0430\u043a\u0436\u0435 \u0448\u0438\u0444\u0440\u0443\u0435\u0442\u0441\u044f \u043f\u043e \u0430\u043b\u0433\u043e\u0440\u0438\u0442\u043c\u0443 \u0432\u044b\u0448\u0435, \u0440\u0435\u0437\u0443\u043b\u044c\u0442\u0430\u0442 \u043f\u0440\u0435\u043e\u0431\u0440\u0430\u0437\u043e\u0432\u044b\u0432\u0430\u0435\u0442\u0441\u044f \u0432 hex \u0438 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0435\u0442\u0441\u044f \u043e\u043a\u043e\u043d\u0447\u0430\u043d\u0438\u0435 <code>.ar<\/code><\/p>\n<p>  <\/p>\n<div class=\"spoiler\"><b class=\"spoiler_title\">\u043a\u043e\u0434<\/b><\/p>\n<div class=\"spoiler_text\">\n<pre><code class=\"javascript\">import chachaAsync from '.\/chacha20'; \/\/ \u0440\u0430\u0441\u0448\u0438\u0440\u0435\u043d\u043d\u0430\u044f \u0432\u0435\u0440\u0441\u0438\u044f chacha \u0434\u043b\u044f \u043f\u043e\u043b\u0443\u0447\u0435\u043d\u0438\u0435 \u043f\u0440\u043e\u0433\u0440\u0435\u0441\u0441\u0430 \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u044f import chacha from 'chacha20'; import { sync as randomBytesSync } from 'random-bytes';  export const NONCE_SIZE = 8; export const KEY_SIZE = 32;  export function generateNonce(){     return randomBytesSync(NONCE_SIZE); }  export function encrypt(buffer, key, nonce, options = {}){     let encrypted = chacha.encrypt(key, nonce, buffer);     if(options.joinNonce)         encrypted = Buffer.concat([nonce, encrypted]);      return encrypted; }  export function decrypt(buffer, key, nonce){     return chacha.decrypt(key, nonce, buffer); }  export function createEncryptJob(buffer, key, nonce){     return chachaAsync.encrypt(buffer, key, nonce); }  export function createDecryptJob(buffer, key, nonce){     return chachaAsync.decrypt(buffer, key, nonce); }<\/code><\/pre>\n<\/div>\n<\/div>\n<p>  <\/p>\n<h3>\u0414\u0435\u0442\u0430\u043b\u0438<\/h3>\n<p>  <\/p>\n<p>\u0414\u043b\u044f ui \u0438\u0441\u043f\u043e\u043b\u044c\u0437\u0443\u0435\u0442\u0441\u044f react + redux, webpack, es6 + es7 decorators<br \/>  \u0427\u0442\u043e\u0431\u044b \u043d\u0435 \u043d\u0430\u0433\u0440\u0443\u0436\u0430\u0442\u044c \u043e\u0441\u043d\u043e\u0432\u043d\u043e\u0439 \u043f\u043e\u0442\u043e\u043a \u2014 \u043e\u0442\u043f\u0440\u0430\u0432\u043a\u0430, \u0441\u043a\u0430\u0447\u0438\u0432\u0430\u043d\u0438\u0435, \u0448\u0438\u0444\u0440\u043e\u0432\u0430\u043d\u0438\u0435 \u0438 \u0440\u0430\u0441\u0448\u0438\u0444\u0440\u043e\u0432\u043a\u0430 \u0444\u0430\u0439\u043b\u043e\u0432 \u0432\u044b\u043f\u043e\u043b\u043d\u044f\u044e\u0442\u0441\u044f \u0432 \u043e\u0442\u0434\u0435\u043b\u044c\u043d\u043e\u043c \u043f\u043e\u0442\u043e\u043a\u0435 (webworkers)<\/p>\n<p>  <\/p>\n<p>\u041d\u0430 \u0434\u0430\u043d\u043d\u044b\u0439 \u043c\u043e\u043c\u0435\u043d\u0442 \u043f\u043e\u0434\u0434\u0435\u0440\u0436\u0438\u0432\u0430\u044e\u0442\u0441\u044f \u0442\u043e\u043b\u044c\u043a\u043e \u043d\u043e\u0432\u0435\u0439\u0448\u0438\u0435 \u0432\u0435\u0440\u0441\u0438\u0438 firefox \u0438 chrome<\/p>\n<p>  <\/p>\n<p>\u0414\u0435\u043c\u043e <a href=\"https:\/\/dropcryptbox.com\">https:\/\/dropcryptbox.com<\/a><br \/>  \u0421\u043e\u0432\u0441\u0435\u043c \u0441\u043a\u043e\u0440\u043e \u043a\u043e\u0434 \u0431\u0443\u0434\u0435\u0442 \u0440\u0430\u0437\u043c\u0435\u0449\u0435\u043d \u043d\u0430 github<\/p>\n<p> \u0441\u0441\u044b\u043b\u043a\u0430 \u043d\u0430 \u043e\u0440\u0438\u0433\u0438\u043d\u0430\u043b \u0441\u0442\u0430\u0442\u044c\u0438 <a href=\"https:\/\/habrahabr.ru\/post\/319004\/\"> https:\/\/habrahabr.ru\/post\/319004\/<\/a><\/p>\n","protected":false},"excerpt":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/habrastorage.org\/files\/cee\/269\/4b1\/cee2694b1733421fac89e20b3dbdacb5.jpg\" alt=\"image\"\/><\/p>\n<p>\u0423 \u043a\u0430\u0436\u0434\u043e\u0433\u043e \u0435\u0441\u0442\u044c \u0441\u0432\u043e\u0438 \u0442\u0430\u0439\u043d\u044b \u0438 \u0447\u0435\u043b\u043e\u0432\u0435\u0447\u0435\u0441\u0442\u0432\u043e \u0432\u0435\u0447\u043d\u043e \u043f\u044b\u0442\u0430\u043b\u043e\u0441\u044c \u043d\u0430\u0445\u043e\u0434\u0438\u0442\u044c \u043f\u0443\u0442\u0438 \u043a\u0430\u043a \u0438\u0445 \u0441\u043a\u0440\u044b\u0442\u0438\u044f \u0442\u0430\u043a \u0438 \u0440\u0430\u0437\u043e\u0431\u043b\u0430\u0447\u0435\u043d\u0438\u044f.<br \/>  \u041f\u043e\u0434 \u043a\u0430\u0442\u043e\u043c \u0431\u0443\u0434\u0435\u0442 \u043e\u043f\u0438\u0441\u0430\u043d \u043e\u0434\u0438\u043d \u0438\u0437 \u0441\u043f\u043e\u0441\u043e\u0431\u043e\u0432 \u0441\u043a\u0440\u044b\u0442\u044c \u0441\u0432\u043e\u0438 \u0444\u0430\u0439\u043b\u044b \u0442\u0430\u043a, \u0447\u0442\u043e\u0431\u044b \u0432\u0430\u0448 \u043f\u0430\u0440\u0430\u043d\u043e\u0438\u043a \u0431\u044b\u043b \u0441\u0447\u0430\u0441\u0442\u043b\u0438\u0432<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-283418","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283418","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=283418"}],"version-history":[{"count":0,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=\/wp\/v2\/posts\/283418\/revisions"}],"wp:attachment":[{"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=283418"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=283418"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/savepearlharbor.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=283418"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}