PM2 command to run ecosystem file

Once the file is properly configured in JSON format, run this command: pm2 start ecosystem.json The output should be similar to this: [PM2] Applying action restartProcessId on app [x509](ids: [ 0 ]) [PM2] [x509](0) ✓ ┌─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────── │ id │ name │ namespace │ version │ mode │ pid │ uptime │ ↺ │ status │ cpu │ mem │ user …

SCRYPT demo in Node.JS v15

SCRYPT is yet another password-based key derivation function that allows you to tweak its arguments in order to discourage brute-force attacks. Basically you can adjust the options to make it slower, and therefore brute-force attacks will need more time to be performed. Here is an example of how to use SCRYPT to generate keys and IVs to use with all …

Password Based Key Derivation Function 2 (PBKDF2) demo in Node.JS v15

A quick demo on how to use Password Based Key Derivation Function 2 (PBKDF2) to generate keys and IVs to use with all different ciphers available in Node.JS v15.x. const crypto = require(‘crypto’); const PASSWORD = “My_Secret_Password”; // Could be the password/key used to encrypt a message const ITERATIONS = 10; const DIGEST = “sha256”; crypto.getCiphers().forEach(cipher => { let cipherInfo …

Node.JS Ciphers Info in version 15.x

After the deprecation of methods createCipher(…) and createDecipher(…) due to the introduction of createCipheriv(…) and createDecipheriv(…) a lot of us had issues when specifying the keys and IVs because sometimes the key would be the incorrect size and same for the IVs. I developed a kind of brute force tester to determine the correct values and keep them in a …

How to Encrypt / Decrypt strings with RSA in Node.JS

Interesting things that go through my mind during lock-down haha! const crypto = require(‘crypto’); const PASSPHRASE = ‘I had learned that some things are best kept secret.’; const KEY_PAIR_OPTIONS = { modulusLength: 2048, publicKeyEncoding: { type: ‘spki’, format: ‘pem’ }, privateKeyEncoding: { type: ‘pkcs8’, format: ‘pem’, cipher: ‘aes-256-cbc’, passphrase: PASSPHRASE } }; const KEY_PAIR = crypto.generateKeyPairSync(‘rsa’, KEY_PAIR_OPTIONS); const RSA_PRK = …

How to deploy Express.JS web application on HawkHost with cPanel?

Here is a step by step guide based on my experience on how to deploy your Express.JS web application with cPanel on HawkHost servers. First, the versions I am using are: cPanel v90.0.16 Express.JS v4.16.0 Node.JS v12.16.1 NPM v6.14.4 Now it’s time to login to your cPanel, and do the following Upload your application folder to the server: You can …

How to generate X.509v3 self-signed certificate in PEM format with Node.JS

I thought this would be way harder, but thanks to the node-forge library and their perfect documentation, this was a breeze! After some experimentation I have modified their example code to have the very basic way to generate a X.509v3 self-signed certificate in PEM format. // import libraries const forge = require(‘node-forge’); const crypto = require(‘crypto’); const fs = require(‘fs’); …

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 …