diff --git a/doc/api/deprecations.md b/doc/api/deprecations.md index 0102c37e2d966a..2f3f420d0d36a4 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 8d49274b33fb81..c7cfdc841be2dc 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 af2146982c7a3b..83218c105a4596 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'], + ] + }); +}