Post
Topic
Board Auctions
Re: [BOUNTY] Mathematica fcns for RIPEMD-160 and base58 coding (0.05 BTC each)
by
CaeZaR
on 21/05/2014, 15:43:13 UTC
For the sake of thorough code, here is some Mathematica that prepends the correct number of leading '1s' according to the Base58Check criteria when you put in the n->25 optional argument.
Code:
Options[Base58Encode] = {n -> None};
Base58Encode[x_Integer, OptionsPattern[]] :=
 StringJoin[
  If[OptionValue[n] === None, "",
   ConstantArray["1",
    Quotient[
     Length[TakeWhile[
       IntegerDigits[x, 16, 2*OptionValue[n]], # == 0 &]], 2]]],
  StringTake[
   "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",
   Partition[1 + IntegerDigits[x, 58], 1]]]
It produces the correct result with the number you give:
Code:
In[55]:= Base58Encode[\
4265945407764313278158431948729033804705681414470582224586, n -> 25]

Out[55]= "1Grv3aiTr82o1kEgYV2QZD8UtLmhqHoBKX"
About your other comments, I don't agree that you have the right to refuse pay based on 4 and 6 as the added work of performing the Base58Check was never part of the bounty described in the OP, and I went beyond the requirements of the bounty to provide you with the additions to the code you wanted.