From 3f7091b39e837c6865999e157d3e5bfe5a341e68 Mon Sep 17 00:00:00 2001 From: Axel Hodler Date: Sat, 27 Jul 2019 19:30:50 +0200 Subject: [PATCH] Support numbers as input for sha1 Else attempting `1 OP_SHA1` in the IDE will get stuck and yield `Uncaught TypeError: msg.utf8Encode is not a function` --- build/script_interpreter/sha1.js | 1 + 1 file changed, 1 insertion(+) diff --git a/build/script_interpreter/sha1.js b/build/script_interpreter/sha1.js index 425beb0c1..d9ff362eb 100644 --- a/build/script_interpreter/sha1.js +++ b/build/script_interpreter/sha1.js @@ -24,6 +24,7 @@ var Sha1 = {}; * @returns {string} Hash of msg as hex character string. */ Sha1.hash = function(msg) { + msg = msg.toString(16); // convert string to UTF-8, as SHA only deals with byte-streams msg = msg.utf8Encode();