From 7e7b25259a45554b8609eb98ef7d34d46f7cb74d Mon Sep 17 00:00:00 2001 From: Yagiz Nizipli Date: Wed, 5 Mar 2025 16:31:51 -0500 Subject: [PATCH] tls: use crypto.hash() for faster sha1 creation --- lib/_tls_wrap.js | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/lib/_tls_wrap.js b/lib/_tls_wrap.js index c44097a31a0a01..88103ca45dd0c6 100644 --- a/lib/_tls_wrap.js +++ b/lib/_tls_wrap.js @@ -1472,9 +1472,7 @@ Server.prototype.setSecureContext = function(options) { if (options.sessionIdContext) { this.sessionIdContext = options.sessionIdContext; } else { - this.sessionIdContext = crypto.createHash('sha1') - .update(process.argv.join(' ')) - .digest('hex') + this.sessionIdContext = crypto.hash('sha1', process.argv.join(' '), 'hex') .slice(0, 32); } @@ -1570,9 +1568,7 @@ Server.prototype.setOptions = deprecate(function(options) { if (options.sessionIdContext) { this.sessionIdContext = options.sessionIdContext; } else { - this.sessionIdContext = crypto.createHash('sha1') - .update(process.argv.join(' ')) - .digest('hex') + this.sessionIdContext = crypto.hash('sha1', process.argv.join(' '), 'hex') .slice(0, 32); } if (options.pskCallback) this[kPskCallback] = options.pskCallback;