diff --git a/lib/crypto/sha256.js b/lib/crypto/sha256.js index 7333fc17..ae292dbd 100644 --- a/lib/crypto/sha256.js +++ b/lib/crypto/sha256.js @@ -18,14 +18,9 @@ const DESC = Buffer.allocUnsafe(8); const BUFFER64 = Buffer.allocUnsafe(64); -let K, PADDING; -let ctx, mctx; +const PADDING = Buffer.allocUnsafe(64); -PADDING = Buffer.allocUnsafe(64); -PADDING.fill(0); -PADDING[0] = 0x80; - -K = [ +const K = [ 0x428a2f98, 0x71374491, 0xb5c0fbcf, 0xe9b5dba5, 0x3956c25b, 0x59f111f1, 0x923f82a4, 0xab1c5ed5, 0xd807aa98, 0x12835b01, 0x243185be, 0x550c7dc3, @@ -44,6 +39,9 @@ K = [ 0x90befffa, 0xa4506ceb, 0xbef9a3f7, 0xc67178f2 ]; +PADDING.fill(0); +PADDING[0] = 0x80; + /** * SHA256 * @alias module:crypto/sha256.SHA256 @@ -341,8 +339,8 @@ function readU32(buf, offset) { * Context Helpers */ -ctx = new SHA256(); -mctx = new SHA256Hmac(); +const ctx = new SHA256(); +const mctx = new SHA256Hmac(); /** * Hash buffer with sha256.