nl_tokens: Encrypt text using AES - GCM
pl_tokens: function encryptGCM ( <mask> , keyDerivationInfo , iv ) { return Promise . resolve ( ) . then ( ( ) => { const ivHex = iv . toString ( "hex" ) ; const { rounds } = keyDerivationInfo ; const encryptTool = crypto . createCipheriv ( ENC_ALGORITHM_GCM , keyDerivationInfo . key , iv ) ; // Add additional auth data encryptTool . setAAD ( new Buffer ( ` ${ ivHex } ${ keyDerivationInfo . salt } ` , "utf8" ) ) ; // Perform encryption let encryptedContent = encryptTool . update ( text , "utf8" , "base64" ) ; encryptedContent += encryptTool . final ( "base64" ) ; // Handle authentication const tag = encryptTool . getAuthTag ( ) ; // Output encrypted components return { mode : "gcm" , iv : ivHex , salt : keyDerivationInfo . salt , rounds , content : encryptedContent , auth : tag . toString ( "hex" ) } ; } ) ; }