Skip to content

Commit ccaba29

Browse files
crypto: runtime deprecate Hash constructor
1 parent fc0f2cf commit ccaba29

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

doc/api/deprecations.md

+4-1
Original file line numberDiff line numberDiff line change
@@ -3563,12 +3563,15 @@ release lines. Please use [`dirent.parentPath`][] instead.
35633563

35643564
<!-- YAML
35653565
changes:
3566+
- version: REPLACEME
3567+
pr-url: https://github.com./nodejs/node/pull/51880
3568+
description: Runtime deprecation.
35663569
- version: v21.5.0
35673570
pr-url: https://github.com./nodejs/node/pull/51077
35683571
description: Documentation-only deprecation.
35693572
-->
35703573

3571-
Type: Documentation-only
3574+
Type: Runtime
35723575

35733576
Calling `Hash` class directly with `Hash()` or `new Hash()` is
35743577
deprecated due to being internals, not intended for public use.

lib/crypto.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ module.exports = {
229229
DiffieHellman,
230230
DiffieHellmanGroup,
231231
ECDH,
232-
Hash,
232+
Hash: deprecate(Hash, 'crypto.Hash constructor is deprecated.', 'DEP0179'),
233233
Hmac,
234234
KeyObject,
235235
Sign,

test/parallel/test-crypto-hash.js

+10
Original file line numberDiff line numberDiff line change
@@ -276,3 +276,13 @@ assert.throws(
276276
assert.strictEqual(a.digest('hex'), b.digest('hex'));
277277
assert.strictEqual(c.digest('hex'), d.digest('hex'));
278278
}
279+
280+
{
281+
crypto.Hash('sha256');
282+
common.expectWarning({
283+
DeprecationWarning: [
284+
['crypto.Hash constructor is deprecated.',
285+
'DEP0179'],
286+
]
287+
});
288+
}

0 commit comments

Comments
 (0)