console.log("Hello, World!"); const MD5 = require('md5'); const SECRET = "Files will never end"; npm install md5 const ALGORITHM = "AES-256-CBC"; const SECRET_IV = "What can you do about it"; const Crypto = require('crypto'); // library const KEY = Crypto.scryptSync(SECRET, 'salt', 32); const IV = MD5(SECRET_IV).slice(0,16); //key : 203465d601854b71b51c74a92023bfb0e677b820dc977f7ac96933a5a7d1a11d const decryptDataFunction = (hash) => new Promise((resolve, reject) => { try{ const DECIPHER = Crypto.createDecipheriv(ALGORITHM, KEY, IV); let decrypted = DECIPHER.update(hash, 'hex', 'utf8'); decrypted += DECIPHER.final('utf8'); resolve(decrypted); } catch (err) { console.error(err); resolve(err); } }); console.log(decryptDataFunction("9e88dcba5f33b23e8cf599513ed7e0b251fc5259635648daa66e2b529f567db9")); const encryptDataFunction = (data) => new Promise((resolve, reject) => { try{ const CIPHER = Crypto.createCipheriv(ALGORITHM, KEY, IV); let encrypted = CIPHER.update(data, 'utf8', 'hex'); encrypted += CIPHER.final('hex'); resolve(encrypted); } catch (err) { console.error(err); resolve(err); } });
Write, Run & Share NodeJS code online using OneCompiler's NodeJS online compiler for free. It's one of the robust, feature-rich online compilers for NodeJS language,running on the latest LTS version NodeJS 16.14.2. Getting started with the OneCompiler's NodeJS editor is easy and fast. The editor shows sample boilerplate code when you choose language as NodeJS and start coding. You can provide the dependencies in package.json
.
Node.js is a free and open-source server environment. Node.js is very popular in recent times and a large number of companies like Microsoft, Paypal, Uber, Yahoo, General Electric and many others are using Node.js.
Google chrome's javascript engine V8
and is pretty fast.Asynchronous
, event-driven
and works on single-thread model
thus eliminating the dis-advantages of multi-thread model.Express is one of the most popular web application framework in the NodeJS echosystem.
let moment = require('moment');
console.log(moment().format('MMMM Do YYYY, h:mm:ss a'));
const _ = require("lodash");
let colors = ['blue', 'green', 'yellow', 'red'];
let firstElement = _.first(colors);
let lastElement = _.last(colors);
console.log(`First element: ${firstElement}`);
console.log(`Last element: ${lastElement}`);
Following are the libraries supported by OneCompiler's NodeJS compiler.