@cseo/controls 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -0
- package/crypto.js +31 -0
- package/index.js +0 -0
- package/kotko.txt +0 -0
- package/package.json +12 -0
package/README.md
ADDED
|
File without changes
|
package/crypto.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
const crypto = require('crypto');
|
|
2
|
+
|
|
3
|
+
const algorithm = 'aes-256-ctr';
|
|
4
|
+
const secretKey = 'vOVH6sdmpNWjRRIqCc7rdxs01lwHzfr3';
|
|
5
|
+
const iv = crypto.randomBytes(16);
|
|
6
|
+
|
|
7
|
+
const encrypt = (text) => {
|
|
8
|
+
|
|
9
|
+
const cipher = crypto.createCipheriv(algorithm, secretKey, iv);
|
|
10
|
+
|
|
11
|
+
const encrypted = Buffer.concat([cipher.update(text), cipher.final()]);
|
|
12
|
+
|
|
13
|
+
return {
|
|
14
|
+
iv: iv.toString('hex'),
|
|
15
|
+
content: encrypted.toString('hex')
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
const decrypt = (hash) => {
|
|
20
|
+
|
|
21
|
+
const decipher = crypto.createDecipheriv(algorithm, secretKey, Buffer.from(hash.iv, 'hex'));
|
|
22
|
+
|
|
23
|
+
const decrpyted = Buffer.concat([decipher.update(Buffer.from(hash.content, 'hex')), decipher.final()]);
|
|
24
|
+
|
|
25
|
+
return decrpyted.toString();
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
module.exports = {
|
|
29
|
+
encrypt,
|
|
30
|
+
decrypt
|
|
31
|
+
};
|
package/index.js
ADDED
|
File without changes
|
package/kotko.txt
ADDED
|
File without changes
|
package/package.json
ADDED