How to use the KeyObject function from crypto
Find comprehensive JavaScript crypto.KeyObject code examples handpicked from public code repositorys.
GitHub: Tanver-Hasan/jose
190 191 192 193 194 195 196 197 198
createSecretKey = (buffer) => { if (!Buffer.isBuffer(buffer) || !buffer.length) { throw new TypeError('input must be a non-empty Buffer instance') } const keyObject = new KeyObject() i(keyObject).buffer = Buffer.from(buffer) i(keyObject).symmetricKeySize = buffer.length i(keyObject).type = 'secret'
279
0
1
+ 3 other calls in file
58 59 60 61 62 63 64 65 66 67
const privateKey = webKeyToPem(keys.privateKey, true) return { certificate: cert.toString('pem'), publicKey, privateKey } } function webKeyToPem (cryptoKey, isPrivate) { return crypto.KeyObject .from(cryptoKey) .export({ type: isPrivate ? 'pkcs8' : 'spki', format: 'pem' }) .toString() }
3
90
8
crypto.createHash is the most popular function in crypto (882 examples)