diff options
author | Valentin Popov <info@valentineus.link> | 2017-09-29 00:32:54 +0300 |
---|---|---|
committer | Valentin Popov <info@valentineus.link> | 2017-09-29 00:32:54 +0300 |
commit | 553ba301ec7a4980b1566f6f459552ce01f73cd3 (patch) | |
tree | f361f03a65e7249f3429670f923509b469574bde | |
parent | 42fa6f65e8ccecf88462b38f1616970cec5a413d (diff) | |
download | iii-client-553ba301ec7a4980b1566f6f459552ce01f73cd3.tar.xz iii-client-553ba301ec7a4980b1566f6f459552ce01f73cd3.zip |
Add compatibility with older versions of NodeJS
-rw-r--r-- | src/index.js | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/index.js b/src/index.js index 7cbf47a..e1c0b4a 100644 --- a/src/index.js +++ b/src/index.js @@ -76,8 +76,8 @@ function send(cuid, text, callback) { * @description Encrypts the received string. */ function encrypt(data) { - var base64 = Buffer.from(data).toString('base64'); - var string = Buffer.from(base64); + var base64 = new Buffer(data).toString('base64'); + var string = new Buffer(base64); return mergerString(string).toString('base64'); } @@ -87,9 +87,9 @@ function encrypt(data) { * @description Decrypts the received string. */ function decrypt(data) { - var string = Buffer.from(data, 'base64'); + var string = new Buffer(data, 'base64'); var decrypted = mergerString(string).toString(); - return Buffer.from(decrypted, 'base64'); + return new Buffer(decrypted, 'base64'); } /** @@ -109,7 +109,7 @@ function decryptJSON(json) { * @description Merges the source string. */ function mergerString(data) { - var salt = Buffer.from('some very-very long string without any non-latin characters due to different string representations inside of variable programming languages'); + var salt = new Buffer('some very-very long string without any non-latin characters due to different string representations inside of variable programming languages'); return data.map((item, index) => { return item ^ salt[index % salt.length]; }); |