Skip to content

Instantly share code, notes, and snippets.

View DannyWhyte's full-sized avatar
🤖

Danish Galiyara DannyWhyte

🤖
  • mumbai,india
View GitHub Profile
@DannyWhyte
DannyWhyte / phases.md
Last active April 2, 2020 06:49
Phases of eventloop explained with example.

Phases of Node JS Event Loop Explained with examples

In this gist i will explain about the working of Phases in Event Loop, please refer below js file and run each example by uncommenting the code snippet one by one.

setImmediate(() => {
  console.log('set immediate 2')
})
setTimeout(() => {
  console.log('timeout 3')
})

process.nextTick(() => {

@DannyWhyte
DannyWhyte / gist.js
Created December 11, 2019 09:47
AES-GCM-256 Encryption & Decryption Using NODE
const crypto = require('crypto');
const generateMasterKey = function (bytes) {
return crypto.randomBytes(bytes).toString('base64')
}
const encryptAes256Gcm = (text, cryptoConfigObject) => {
try {
// random initialization vector
const iv = crypto.randomBytes(16);
@DannyWhyte
DannyWhyte / gist.md
Created December 11, 2019 09:40
Cross-Platform AES-GCM-256 Encryption & Decryption using JAVA to encrypt and NODE to decrypt

This snippet is about cross-platform AES-GCM-256 encryption & decryption, Where payload is being encrypted using JAVA and decrypted using NODE

sample config :

{
    "masterKey": "sfcpnnjFG6dULJfo1BEGqczpfN0SmwZ6bgKO5FcDRfI=",
    "iterations": 2333,
    "keyLength": 32,

"digest": "sha512"