diff --git a/lib/client.js b/lib/client.js index 3e393e50..aa94ace0 100644 --- a/lib/client.js +++ b/lib/client.js @@ -273,16 +273,14 @@ class Client extends EventEmitter { let hostVerifier; if (typeof cfg.hostVerifier === 'function') { const hashCb = cfg.hostVerifier; - let hasher; + let hashAlgo; if (HASHES.indexOf(cfg.hostHash) !== -1) { // Default to old behavior of hashing on user's behalf - hasher = createHash(cfg.hostHash); + hashAlgo = cfg.hostHash; } hostVerifier = (key, verify) => { - if (hasher) { - hasher.update(key); - key = hasher.digest('hex'); - } + if (hashAlgo) + key = createHash(hashAlgo).update(key).digest('hex'); const ret = hashCb(key, verify); if (ret !== undefined) verify(ret);