How to use the getCipherInfo function from crypto
Find comprehensive JavaScript crypto.getCipherInfo code examples handpicked from public code repositorys.
GitHub: nwjs/node
120 121 122 123 124 125 126 127 128 129
const cryptoCiphers = crypto.getCiphers(); assert(crypto.getCiphers().includes('aes-128-cbc')); validateList(cryptoCiphers); // Make sure all of the ciphers are supported by OpenSSL for (const algo of cryptoCiphers) { const { ivLength, keyLength, mode } = crypto.getCipherInfo(algo); let options; if (mode === 'ccm') options = { authTagLength: 8 }; else if (mode === 'ocb' || algo === 'chacha20-poly1305')
42
19
0
GitHub: akeneo/sample-apps
2 3 4 5 6 7 8 9 10 11 12 13
class Codec { static algorithm = "aes-256-ctr"; static encoder(payload, key) { const iv_length = crypto.getCipherInfo(Codec.algorithm).ivLength; const iv = crypto.randomBytes(iv_length); const cipher = crypto.createCipheriv(Codec.algorithm, key, iv) const encodedSub = cipher.update(payload, 'utf8', 'hex') + cipher.final('hex') const encodedIv = iv.toString('hex');
2
4
0
crypto.createHash is the most popular function in crypto (882 examples)