This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); |