Browse Source

Explicit check for invalid characters in Base58 decoder.

hk-custom-address
justmoon 13 years ago
parent
commit
c952aaeb3e
  1. 4
      src/base58.js

4
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)));

Loading…
Cancel
Save