Commit inicial
This commit is contained in:
commit
974722690b
21
crypto.js
Normal file
21
crypto.js
Normal file
@ -0,0 +1,21 @@
|
||||
const crypto = require('crypto');
|
||||
const CHAVE = 'bf3c199c2470cb477d907b1e0917c17e'; // 32
|
||||
const IV = "5183666c72eec9e4"; // 16
|
||||
const ALGORITMO = "aes-256-cbc";
|
||||
const METODO_CRIPTOGRAFIA = 'hex';
|
||||
const METODO_DESCRIPTOGRAFIA = 'hex';
|
||||
|
||||
const encrypt = ((text) => {
|
||||
let cipher = crypto.createCipheriv(ALGORITMO, CHAVE, IV);
|
||||
let encrypted = cipher.update(text, 'utf8', METODO_CRIPTOGRAFIA);
|
||||
encrypted += cipher.final(METODO_CRIPTOGRAFIA);
|
||||
return encrypted;
|
||||
});
|
||||
|
||||
const decrypt = ((text) => {
|
||||
let decipher = crypto.createDecipheriv(ALGORITMO, CHAVE, IV);
|
||||
let decrypted = decipher.update(text, METODO_DESCRIPTOGRAFIA, 'utf8');
|
||||
return (decrypted + decipher.final('utf8'));
|
||||
});
|
||||
|
||||
module.exports = {encrypt, decrypt};
|
6
index.js
Normal file
6
index.js
Normal file
@ -0,0 +1,6 @@
|
||||
const crypto = require('./crypto');
|
||||
|
||||
const encrypted_key = crypto.encrypt("HelloWorld");
|
||||
console.log(encrypted_key);
|
||||
const decrypted_key = crypto.decrypt(encrypted_key);
|
||||
console.log(decrypted_key);
|
14
node_modules/.package-lock.json
generated
vendored
Normal file
14
node_modules/.package-lock.json
generated
vendored
Normal file
@ -0,0 +1,14 @@
|
||||
{
|
||||
"name": "crypto",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"node_modules/crypto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
|
||||
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==",
|
||||
"deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in."
|
||||
}
|
||||
}
|
||||
}
|
7
node_modules/crypto/README.md
generated
vendored
Normal file
7
node_modules/crypto/README.md
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
# Deprecated Package
|
||||
|
||||
This package is no longer supported and has been deprecated. To avoid malicious use, npm is hanging on to the package name.
|
||||
|
||||
It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in.
|
||||
|
||||
Please contact support@npmjs.com if you have questions about this package.
|
19
node_modules/crypto/package.json
generated
vendored
Normal file
19
node_modules/crypto/package.json
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
{
|
||||
"name": "crypto",
|
||||
"version": "1.0.1",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/npm/deprecate-holder.git"
|
||||
},
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"bugs": {
|
||||
"url": "https://github.com/npm/deprecate-holder/issues"
|
||||
},
|
||||
"homepage": "https://github.com/npm/deprecate-holder#readme"
|
||||
}
|
29
package-lock.json
generated
Normal file
29
package-lock.json
generated
Normal file
@ -0,0 +1,29 @@
|
||||
{
|
||||
"name": "crypto",
|
||||
"version": "1.0.0",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "crypto",
|
||||
"version": "1.0.0",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"crypto": "^1.0.1"
|
||||
}
|
||||
},
|
||||
"node_modules/crypto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
|
||||
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig==",
|
||||
"deprecated": "This package is no longer supported. It's now a built-in Node module. If you've depended on crypto, you should switch to the one that's built-in."
|
||||
}
|
||||
},
|
||||
"dependencies": {
|
||||
"crypto": {
|
||||
"version": "1.0.1",
|
||||
"resolved": "https://registry.npmjs.org/crypto/-/crypto-1.0.1.tgz",
|
||||
"integrity": "sha512-VxBKmeNcqQdiUQUW2Tzq0t377b54N2bMtXO/qiLa+6eRRmmC4qT3D4OnTGoT/U6O9aklQ/jTwbOtRMTTY8G0Ig=="
|
||||
}
|
||||
}
|
||||
}
|
15
package.json
Normal file
15
package.json
Normal file
@ -0,0 +1,15 @@
|
||||
{
|
||||
"name": "crypto",
|
||||
"version": "1.0.0",
|
||||
"description": "",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "echo \"Error: no test specified\" && exit 1"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"dependencies": {
|
||||
"crypto": "^1.0.1"
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user