Search
 
SCRIPT & CODE EXAMPLE
 

TYPESCRIPT

nodejs encryption 128bit

import * as crypto from "crypto";

const algorithm:string = 'aes-128-ecb';
const key:Buffer = crypto.randomBytes(16);

// Encryption
const plaintextEnc:Buffer = Buffer.from('0123456789012345');
const cipherEnc:crypto.Cipher = crypto.createCipheriv(algorithm, key, null);
cipherEnc.setAutoPadding(false);        
const ciphertext:Buffer = Buffer.concat([cipherEnc.update(plaintextEnc), cipherEnc.final()]);
console.log(ciphertext.toString('hex')); 

// Decryption
const cipherDec:crypto.Decipher = crypto.createDecipheriv(algorithm, key, null);
cipherDec.setAutoPadding(false);
const plaintextDec:Buffer = Buffer.concat([cipherDec.update(ciphertext), cipherDec.final()]);
console.log(plaintextDec.toString('hex'));
Comment

PREVIOUS NEXT
Code Example
Typescript :: in what phaseof meiosisof prophase1 homologous chrosomes gets close to each other 
Typescript :: typescript for vue 
Typescript :: python list comports on windows 
Typescript :: Where is the requirement engineering heading? 
Typescript :: global hotkeys typescript react 
Typescript :: vim show different parts of same file 
Typescript :: typescript sugar syntax 
Typescript :: TypeScript interface for object with arbitrary numeric property names? 
Typescript :: wrapper tsx 
Typescript :: How to disabele and enable the button when it valid 
Typescript :: how can i get 2 inputs in singal line seprated by space 
Typescript :: mkdir windows 
Typescript :: Passing a generic function in as a callback in Typescript 
Typescript :: adding objects to existing legend 
Typescript :: a device that interconnects two local area networks that both have a medium access control sublayer. 
Typescript :: exits adn copy file in java 
Typescript :: use array element as types 
Typescript :: formControl Server Side rendering 
Typescript :: what version of python supports kivy 
Typescript :: c# check type implements generic interface 
Typescript :: set typescript 
Typescript :: how to make dots react native 
Typescript :: Alert cannot operate on nodes the current scene inherits from 
Cpp :: how to convert string to wchar_t in c++ 
Cpp :: c++ hide console 
Cpp :: c++ iterate map using auto 
Cpp :: modify file cpp 
Cpp :: stoi c++ 
Cpp :: sony pictures animation films produced 
Cpp :: C++ Kelvin to Celsius 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =