diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 0102c37e2d9..2f3f420d0d3 100644 --- a/doc/api/deprecations.md +++ b/doc/api/deprecations.md @@ -3563,12 +3563,15 @@ release lines. Please use [`dirent.parentPath`][] instead. -Type: Documentation-only +Type: Runtime Calling `Hash` class directly with `Hash()` or `new Hash()` is deprecated due to being internals, not intended for public use. diff --git a/lib/crypto.js b/lib/crypto.js index 8d49274b33f..c7cfdc841be 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -231,7 +231,7 @@ module.exports = { DiffieHellman, DiffieHellmanGroup, ECDH, - Hash, + Hash: deprecate(Hash, 'crypto.Hash constructor is deprecated.', 'DEP0179'), Hmac, KeyObject, Sign, diff --git a/test/parallel/test-crypto-hash.js b/test/parallel/test-crypto-hash.js index af2146982c7..83218c105a4 100644 --- a/test/parallel/test-crypto-hash.js +++ b/test/parallel/test-crypto-hash.js @@ -276,3 +276,13 @@ assert.throws( assert.strictEqual(a.digest('hex'), b.digest('hex')); assert.strictEqual(c.digest('hex'), d.digest('hex')); } + +{ + crypto.Hash('sha256'); + common.expectWarning({ + DeprecationWarning: [ + ['crypto.Hash constructor is deprecated.', + 'DEP0179'], + ] + }); +}