ByTekLab
  • Home
  • Acronyms
  • Cheat-Sheets
  • User Manuals

Node.JS

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(
Hector Perez 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('
Hector Perez 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('
Hector Perez 18 Jul 2016
ByTekLab © 2025. Powered by Ghost