From f08f6ca0a9d337efff280d4d1669a41b5d9c31c2 Mon Sep 17 00:00:00 2001 From: piotrruss Date: Thu, 2 Sep 2021 22:28:11 +0200 Subject: finish translations, force maximize --- lib/crypt.js | 19 ------------------- 1 file changed, 19 deletions(-) delete mode 100644 lib/crypt.js (limited to 'lib/crypt.js') diff --git a/lib/crypt.js b/lib/crypt.js deleted file mode 100644 index 5d3d79e..0000000 --- a/lib/crypt.js +++ /dev/null @@ -1,19 +0,0 @@ -const crypto = require('crypto') -const algorithm = 'aes-256-ctr' -const secretKey = process.env.MYAPPS_NOTES_KEY - -export const encrypt = (text) => { - const iv = crypto.randomBytes(16) - const cipher = crypto.createCipheriv(algorithm, secretKey, iv) - const encrypted = Buffer.concat([cipher.update(text), cipher.final()]) - - return iv.toString('hex') + '::' + encrypted.toString('hex') -} - -export const decrypt = (hash) => { - const [iv, content] = hash.split('::') - const decipher = crypto.createDecipheriv(algorithm, secretKey, Buffer.from(iv, 'hex')) - const decrpyted = Buffer.concat([decipher.update(Buffer.from(content, 'hex')), decipher.final()]) - - return decrpyted.toString(); -} -- cgit v1.2.3