Anonymous user
Base58Check encoding: Difference between revisions
m
→version 3: simplified code, changed comments and whitespace.
(Added Quackery.) |
m (→version 3: simplified code, changed comments and whitespace.) |
||
Line 1,224:
The algorithm used doesn't need to ''reverse'' the residual string (it uses ''prepend'' instead of ''append'').
<lang rexx>/*REXX pgm encodes a checksum (hash digest) into Base58 (the standard Bitcoin alphabet).*/
call B58 25420294593250030202636073700053352635053786165627414518▼
@= space(" 123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghi jkmnopqrstuvwxyz", 0)▼
say B58('61'x); say B58('626262'x)
say B58('572e4794'x); say B58('ecac89cad93923c02321'x)
▲exit /*stick a fork in it, we're all done. */
/*──────────────────────────────────────────────────────────────────────────────────────*/
B58: parse arg z 1 oz,,$; L1= 0;
if \datatype(z, 'W') | arg()>1 then
if left(z, 1)==1 then L1= verify(z ., 1) - 1 /*count number of leading ones (1's
do until z==0; $= substr(@, z//58 +1, 1)$; z= z % 58
▲ /* 0─────────────────I─────O────────────────────l──────────────── ◄───omit.*/
▲ @=space(" 123456789ABCDEFGH JKLMN PQRSTUVWXYZabcdefghi jkmnopqrstuvwxyz", 0)
▲ do until z=0; $=substr(@, z//58 +1, 1)$; z=z % 58
end /*until*/
if
{{out|output|text= when using the default inputs:}}
<pre>
25420294593250030202636073700053352635053786165627414518 ───► 6UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM
|