Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions lib/internal/crypto/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ const maybeEmitDeprecationWarning = getDeprecationWarningEmitter(
},
);

const maybeEmitHMACMultipleDigestDeprecationWarning =
getDeprecationWarningEmitter(
'DEP0208',
'Calling hmac.digest() multiple times without re-initialization is ' +
'deprecated and will throw an error in a future version.',
);

function Hash(algorithm, options) {
if (!new.target)
return new Hash(algorithm, options);
Expand Down Expand Up @@ -186,6 +193,7 @@ Hmac.prototype.digest = function digest(outputEncoding) {
const state = this[kState];

if (state[kFinalized]) {
maybeEmitHMACMultipleDigestDeprecationWarning();
const buf = Buffer.from('');
if (outputEncoding && outputEncoding !== 'buffer')
return buf.toString(outputEncoding);
Expand Down
Loading