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 = …

Random Password Generator in Node.JS

The other day I thought about how to generate passwords from random arrays. Here is what I came up with: /* * RaNdom Password Generator */ const crypto = require(‘crypto’); const PASSWORD_LENGTH = 18; const LOWERCASE_ALPHABET = ‘abcdefghijklmnopqrstuvwxyz’; // 26 chars const UPPERCASE_ALPHABET = ‘ABCDEFGHIJKLMNOPQRSTUVWXYZ’; // 26 chars const NUMBERS = ‘0123456789’; // 10 chars const SYMBOLS = ‘,./<>?;\'”:[]\\|}{=-_+`~!@#$%^&*()’; // …

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’); …

Markdown cheat sheet for Visual Studio Code

Here is a cheat sheet that I found somewhere that will work with Visual Studio Code MD files: “# README” <!– M A R K D O W N   C H E A T  S H E E T –><!– Headings –># Heading 1## Heading 2### Heading 3#### Heading 4##### Heading 5###### Heading 6<!– Italics –>*This text* is italic\*This text\* is not italic_This text_ is italic<!– Strong …