Skip to content

Commit

Permalink
crypto: remove unnecessary buffer initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Jul 25, 2024
1 parent 82cf0f2 commit 16877cb
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/internal/crypto/hash.js
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,7 @@ Hmac.prototype.digest = function digest(outputEncoding) {
const state = this[kState];

if (state[kFinalized]) {
const buf = Buffer.from('');
if (outputEncoding && outputEncoding !== 'buffer')
return buf.toString(outputEncoding);
return buf;
return !outputEncoding || outputEncoding === 'buffer' ? Buffer.from('') : '';
}

// Explicit conversion of truthy values for backward compatibility.
Expand Down

0 comments on commit 16877cb

Please sign in to comment.