How to use the subtle function from crypto
Find comprehensive JavaScript crypto.subtle code examples handpicked from public code repositorys.
-3 -2 -1
// JSDom does not include a full implementation of webcrypto const crypto = require('crypto').webcrypto; global.crypto.subtle = crypto.subtle;
493
0
151
+ 3 other calls in file
67 68 69 70 71 72 73 74 75
const cryptoKey = await crypto.subtle.importKey( 'raw', keyBytes, { name: 'HMAC', hash: 'SHA-256' }, true, ['sign'] ); const sig = await crypto.subtle.sign('HMAC', cryptoKey, messageBytes); // to lowercase hexits [...new Uint8Array(sig)].map(b => b.toString(16).padStart(2, '0')).join('');
52
280
9
+ 3 other calls in file
3 4 5 6 7 8 9 10 11 12
console.log('in generatePKCE'); const code_verifier = generateRandomString(); const encoder = new TextEncoder(); const data = encoder.encode(code_verifier); const sha256 = await crypto.subtle.digest('SHA-256', data); let str = ''; const bytes = new Uint8Array(sha256); const len = bytes.byteLength;
0
0
0
crypto.createHash is the most popular function in crypto (882 examples)