From 974722690bbc4d883be68e4fc505fc512f2fd967 Mon Sep 17 00:00:00 2001 From: "Luiz F. Picolo" Date: Fri, 15 Sep 2023 13:10:53 -0400 Subject: [PATCH] Commit inicial --- crypto.js | 21 +++++++++++++++++++++ index.js | 6 ++++++ node_modules/.package-lock.json | 14 ++++++++++++++ node_modules/crypto/README.md | 7 +++++++ node_modules/crypto/package.json | 19 +++++++++++++++++++ package-lock.json | 29 +++++++++++++++++++++++++++++ package.json | 15 +++++++++++++++ 7 files changed, 111 insertions(+) create mode 100644 crypto.js create mode 100644 index.js create mode 100644 node_modules/.package-lock.json create mode 100644 node_modules/crypto/README.md create mode 100644 node_modules/crypto/package.json create mode 100644 package-lock.json create mode 100644 package.json diff --git a/crypto.js b/crypto.js new file mode 100644 index 0000000..92f47ca --- /dev/null +++ b/crypto.js @@ -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}; \ No newline at end of file diff --git a/index.js b/index.js new file mode 100644 index 0000000..39fd8ab --- /dev/null +++ b/index.js @@ -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); \ No newline at end of file diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json new file mode 100644 index 0000000..b73c912 --- /dev/null +++ b/node_modules/.package-lock.json @@ -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." + } + } +} diff --git a/node_modules/crypto/README.md b/node_modules/crypto/README.md new file mode 100644 index 0000000..5437f14 --- /dev/null +++ b/node_modules/crypto/README.md @@ -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. diff --git a/node_modules/crypto/package.json b/node_modules/crypto/package.json new file mode 100644 index 0000000..01aa4d3 --- /dev/null +++ b/node_modules/crypto/package.json @@ -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" +} diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..38f3835 --- /dev/null +++ b/package-lock.json @@ -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==" + } + } +} diff --git a/package.json b/package.json new file mode 100644 index 0000000..2b04b38 --- /dev/null +++ b/package.json @@ -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" + } +}