Skip to content

Commit 7e7b252

Browse files
committed
tls: use crypto.hash() for faster sha1 creation
1 parent 2bf0bd2 commit 7e7b252

File tree

1 file changed

+2
-6
lines changed

1 file changed

+2
-6
lines changed

lib/_tls_wrap.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1472,9 +1472,7 @@ Server.prototype.setSecureContext = function(options) {
14721472
if (options.sessionIdContext) {
14731473
this.sessionIdContext = options.sessionIdContext;
14741474
} else {
1475-
this.sessionIdContext = crypto.createHash('sha1')
1476-
.update(process.argv.join(' '))
1477-
.digest('hex')
1475+
this.sessionIdContext = crypto.hash('sha1', process.argv.join(' '), 'hex')
14781476
.slice(0, 32);
14791477
}
14801478

@@ -1570,9 +1568,7 @@ Server.prototype.setOptions = deprecate(function(options) {
15701568
if (options.sessionIdContext) {
15711569
this.sessionIdContext = options.sessionIdContext;
15721570
} else {
1573-
this.sessionIdContext = crypto.createHash('sha1')
1574-
.update(process.argv.join(' '))
1575-
.digest('hex')
1571+
this.sessionIdContext = crypto.hash('sha1', process.argv.join(' '), 'hex')
15761572
.slice(0, 32);
15771573
}
15781574
if (options.pskCallback) this[kPskCallback] = options.pskCallback;

0 commit comments

Comments
 (0)