Skip to content

Commit

Permalink
tls: use crypto.hash() for faster sha1 creation
Browse files Browse the repository at this point in the history
  • Loading branch information
anonrig committed Mar 5, 2025
1 parent 2bf0bd2 commit 7e7b252
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions lib/_tls_wrap.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 7e7b252

Please sign in to comment.