Skip to content

crypto: remove default encoding from Hash/Hmac

getDefaultEncoding() always returns 'buffer' in Node.js 20. It requires some careful justification but the default encoding can be eliminated from hash.js entirely. The reasoning is almost identical with that in https://github.com/nodejs/node/pull/49145 so I won't repeat it here. The main thing to note here is that digest() conveniently defaults to BUFFER for falsy encodings.

This partially addresses:

https://github.com/nodejs/node/blob/af9b48a2f17b11b66a8b81beeaba3c408b863795/lib/internal/crypto/util.js#L77-L80

Refs: https://github.com/nodejs/node/pull/47182

Merge request reports

Loading