Skip to content

Commit

Permalink
add leading zeroes for Base58 decode
Browse files Browse the repository at this point in the history
  • Loading branch information
fluency03 committed May 9, 2018
1 parent 4256680 commit 23089af
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,11 @@ object Base58 {
restoreBigInt(chars, bi * 58 + i, idx + 1)
}

val bi = restoreBigInt(str.toCharArray, 0, 0)
Hex.decode(bi.toString(16))
val zeroes = str.takeWhile(_ == '1').map(_ => 0: Byte).toArray
val trim = str.dropWhile(_ == '1').toCharArray

val bi = restoreBigInt(trim, 0, 0)
zeroes ++ Hex.decode(bi.toString(16))
}

def decodeToHex(str: String): String = new String(decode(str))
Expand Down

0 comments on commit 23089af

Please sign in to comment.