diff --git a/src/base58.js b/src/base58.js index c64683d..9313c55 100644 --- a/src/base58.js +++ b/src/base58.js @@ -1,6 +1,7 @@ (function (Bitcoin) { Bitcoin.Base58 = { alphabet: "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", + validRegex: /^[1-9A-HJ-NP-Za-km-z]+$/, base: BigInteger.valueOf(58), /** @@ -45,6 +46,9 @@ var leadingZerosNum = 0; for (var i = input.length - 1; i >= 0; i--) { var alphaIndex = B58.alphabet.indexOf(input[i]); + if (alphaIndex < 0) { + throw "Invalid character"; + } bi = bi.add(BigInteger.valueOf(alphaIndex) .multiply(B58.base.pow(input.length - 1 -i)));