> Command_Prompt_Blog \
  • Home
  • Acronyms
  • Cheat-Sheets
  • User Manuals

Node.js

How to Encrypt / Decrypt with AES in Node.JS

Easy as pie! var crypto = require('crypto'); var AES128 = "aes128"; var AES192 = "aes192"; var AES256 = "aes256"; var password = 'Austin'; var plainText = 'Texas to the bone!'; // ------------------------------------------------ var cipher = crypto.createCipher(AES128, password); var decipher = crypto.createDecipher(AES128, password)
Hec P. 08 Dec 2017

How to Encode / Decode to / from base64 in Node.JS

Today I ran into this basic problem. A quick search on google gave me the answer, I tested it, it worked, and the rest is history. Here is the code. let plainText = "Hello World!"; console.log("Plaint text = " + plainText); // Encoding to base64 let base64 = new Buffer(
Hec P. 18 Jul 2017

How to generate SHA256HMAC in Node.JS

Today I had to do this for my job (hash some info) and I think is a good opportunity to share the knowledge. Here is the code, you can simply copy it and paste it in a file called SHA256Hmac.js and run it. let crypto; try { crypto = require('
Hec P. 17 Mar 2017

How to convert a String into JSON object in Node.JS

Just a few days ago I needed to do this and I found this useful function. Very simple: var jsonStr = "{"firstName":"Siry", "lastName":"Mazari"}"; console.log('JSON String: %s', jsonStr); var jsonObj = JSON.parse(jsonStr); console.log('
Hec P. 18 Jul 2016
> Command_Prompt_Blog \ © 2026. Powered by Ghost