diff --git a/src/base58.js b/src/base58.js index 0b38586..3715c3b 100644 --- a/src/base58.js +++ b/src/base58.js @@ -1,66 +1,65 @@ -// https://en.bitcoin.it/wiki/Base58Check_encoding +// Base58 encoding/decoding +// Originally written by Mike Hearn for BitcoinJ +// Copyright (c) 2011 Google Inc +// Ported to JavaScript by Stefan Thomas var BigInteger = require('./jsbn/jsbn') -var Crypto = require('crypto-js') -var convert = require('./convert') -var SHA256 = Crypto.SHA256 +// FIXME: ? This is a Base58Check alphabet var alphabet = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz" var base = BigInteger.valueOf(58) -var positions = {} +var alphabetMap = {} for (var i=0; i= 0) { var mod = bi.mod(base) - chars.push(alphabet[mod.intValue()]) bi = bi.subtract(mod).divide(base) + + chars.push(alphabet[mod.intValue()]) } chars.push(alphabet[bi.intValue()]) // Convert leading zeros too. - for (var i=0; i