Skip to content

Instantly share code, notes, and snippets.

View VimanyuAgg's full-sized avatar

Vimanyu Aggarwal VimanyuAgg

View GitHub Profile
@VimanyuAgg
VimanyuAgg / aes_gcm_decryption.java
Created December 9, 2020 07:09
aes_gcm_decryption java
import javax.crypto.SecretKey;
import javax.crypto.Cipher;
import javax.crypto.KeyGenerator;
import javax.crypto.SecretKey;
import javax.crypto.spec.GCMParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.util.Arrays;
import java.util.Base64;
class Main {
@VimanyuAgg
VimanyuAgg / aes_gcm_encrypt_decrypt.js
Created December 9, 2020 07:05
AES GCM Encryption/Decryption nodejs
const IV_LENGTH = 12;
var crypto = require('crypto'),
password = 'AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA' //32 bytes (128 bits)
iv = crypto.randomBytes(IV_LENGTH);
var cipher = crypto.createCipheriv('aes-256-gcm',password, iv);
var encrypted = Buffer.from(iv).toString('hex');
encrypted += cipher.update("mysuperSecretText", 'utf8', 'hex');
encrypted += cipher.final('hex');