How to parse JSON files in Node.JS ?

Quick tip using fs: let data = fs.readFileSync(“myFile.json”, ‘utf8’); console.log(typeof JSON.parse(data)); There is another way to do this that requires less effort. Using require directly, like so: const data = require(“myFile.json”); console.log(typeof data); Or you can create a function like this with fs also: function loadAlgorithms(fName) { let data = fs.readFileSync(fName, ‘utf8’); return JSON.parse(data); } Hope it helps.

How to pack NodeJS project into a tarball?

Today I needed to install my brand new NodeJS-developed CLI application in my computer. Important! Don’t forget to add this to your package.json file:  “bin”: {    “skynet”: “./bin/skynetApp.js”   }, It’s basically the name of the command and the NodeJS file it will execute, in this case the command name is skynet and every time this is typed in a terminal window it …

How to hash files in Node.JS

The process is quite simple actually. Unfortunately ,as much things in Node.js, it works asynchronously, for some applications this will be perfect, but for some others it will be a mess to wait for the freaking hash to do something else, anyway I am not going to discuss that here I actually like Node.js. Please note that in the following …

How to generate RSA key pair in Node.JS?

Very straight forward process. Not complicated at all, I would say that the most difficult part would be to actually tweak the options, however the code below actually works and provides you the time it took to generate the key pair as well, just for informational purposes. Run the following code in Node.js. const crypto = require(‘crypto’); const RSA = …

vManage API to GUI mapping

I’ve been working with vManage APIs for a while now, and if there is something clear to me is that is quite difficult sometimes to find information on the internet about a specific URL, meaning to find the accurate description of requests and responses. I’ve decided that I will add to this post all each URL and where to find …

How to hash files in Linux?

How many times have you needed to get the hash of any file in Linux? For whatever purpose you have needed to do that, rest assured that there is a set of commands that will make your life easier. These commands are part of Linux core utils. MD5 md5sum <file_name> SHA-1 sha1sum <file_name> SHA-256 sha256sum <file_name> SHA-384 sha384sum <file_name> SHA-512 …

How to create a Node.JS application with Express Generator

I am assuming that you already have Node.JS installed. If you don’t, worry not! you can get your own copy today from the Node.JS download section! Using ExpressJS is very quick and easy. It generates all the file structure needed for a web application. You can select  any of the different views they have available, in this case I am …

How to Encrypt / Decrypt with AES (CCM & GCM) in Node.JS

First of all we have to understand what is CCM mode and GCM mode. Roughly: CCM CCM mode (Counter with CBC-MAC) is a mode of operation for cryptographic block ciphers. It is an authenticated encryption algorithm designed to provide both authentication and confidentiality. CCM mode is only defined for block ciphers with a block length of 128 bits. GCM Galois/Counter …