|
|
@ -24,9 +24,9 @@ var base58 = { |
|
|
|
str = new Buffer(buf.length << 1); |
|
|
|
} |
|
|
|
var i = str.length - 1; |
|
|
|
while (x.gt(new bignum(0))) { |
|
|
|
r = x.mod(new bignum(58)); |
|
|
|
x = x.div(new bignum(58)); |
|
|
|
while (x.gt(0)) { |
|
|
|
r = x.mod(58); |
|
|
|
x = x.div(58); |
|
|
|
str[i] = ALPHABET_BUF[r.toNumber()]; |
|
|
|
i--; |
|
|
|
} |
|
|
@ -44,10 +44,10 @@ var base58 = { |
|
|
|
|
|
|
|
decode: function(str) { |
|
|
|
if (str.length == 0) return zerobuf; |
|
|
|
var answer = new bignum(0); |
|
|
|
var answer = bignum(0); |
|
|
|
for (var i = 0; i < str.length; i++) { |
|
|
|
answer = answer.mul(new bignum(58)); |
|
|
|
answer = answer.add(new bignum(ALPHABET_INV[str[i]])); |
|
|
|
answer = answer.mul(58); |
|
|
|
answer = answer.add(ALPHABET_INV[str[i]]); |
|
|
|
}; |
|
|
|
var i = 0; |
|
|
|
while (i < str.length && str[i] == ALPHABET_ZERO) { |
|
|
|