MCPcopy Index your code
hub / github.com/nodejs/node / encryptImpl

Function encryptImpl

lib/internal/crypto/webcrypto.js:1274–1297  ·  view source on GitHub ↗
(algorithm, key, data)

Source from the content-addressed store, hash-verified

1272}
1273
1274function encryptImpl(algorithm, key, data) {
1275 const prefix = prepareSubtleMethod(this, 'encrypt', arguments.length, 3);
1276 let i = 0;
1277 algorithm = convertSubtleArgument(
1278 prefix, 'AlgorithmIdentifier', algorithm, i++);
1279 key = convertSubtleArgument(prefix, 'CryptoKey', key, i++);
1280 data = convertSubtleArgument(prefix, 'BufferSource', data, i++);
1281
1282 const normalizedAlgorithm = normalizeAlgorithm(algorithm, 'encrypt');
1283
1284 if (normalizedAlgorithm.name !== getCryptoKeyAlgorithm(key).name)
1285 throw lazyDOMException('Key algorithm mismatch', 'InvalidAccessError');
1286
1287 if (!hasCryptoKeyUsage(key, 'encrypt'))
1288 throw lazyDOMException(
1289 'Unable to use this key to encrypt', 'InvalidAccessError');
1290
1291 return cipherOrWrap(
1292 kWebCryptoCipherEncrypt,
1293 normalizedAlgorithm,
1294 key,
1295 data,
1296 );
1297}
1298
1299function decrypt(algorithm, key, data) {
1300 return callSubtleCryptoMethod(decryptImpl, this, arguments);

Callers

nothing calls this directly

Calls 7

prepareSubtleMethodFunction · 0.85
convertSubtleArgumentFunction · 0.85
getCryptoKeyAlgorithmFunction · 0.85
lazyDOMExceptionFunction · 0.85
hasCryptoKeyUsageFunction · 0.85
cipherOrWrapFunction · 0.85
normalizeAlgorithmFunction · 0.70

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…