Base58Check encoding: Difference between revisions
Content added Content deleted
(Scala contribution added.) |
(Added Sidef) |
||
Line 1,199: | Line 1,199: | ||
16#10c8511e -> Rt5zm</pre> |
16#10c8511e -> Rt5zm</pre> |
||
=={{header|Sidef}}== |
|||
{{trans|Perl 6}} |
|||
<lang ruby>func encode_base58(n) { |
|||
static chars = %w( |
|||
1 2 3 4 5 6 7 8 9 |
|||
A B C D E F G H J K L M N P Q R S T U V W X Y Z |
|||
a b c d e f g h i j k m n o p q r s t u v w x y z |
|||
) |
|||
[n.polymod(n.ilog(58).of(58)...)].map { chars[_] }.join.flip |
|||
} |
|||
var tests = [ |
|||
[25420294593250030202636073700053352635053786165627414518, "6UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM"], |
|||
[97, "2g"],[6447714, "a3gV"],[6513507, "aPEr"], |
|||
[658885050385564465925592505944209249682185612903, "2cFupjhnEsSn59qHXstmK2ffpLv2"], |
|||
[349694840079, "ABnLTmg"], [3529059230209907258589, "3SEo3LWLoPntC"], |
|||
[1462650772, "3EFU7m"], [1117661258925082241147681, "EJDM8drfXA6uyA"], [281563422, "Rt5zm"] |
|||
] |
|||
for num, enc in (tests) { |
|||
printf("%56s -> %s\n", num, encode_base58(num)) |
|||
assert_eq(encode_base58(num), enc) |
|||
}</lang> |
|||
{{out}} |
|||
<pre> |
|||
25420294593250030202636073700053352635053786165627414518 -> 6UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM |
|||
97 -> 2g |
|||
6447714 -> a3gV |
|||
6513507 -> aPEr |
|||
658885050385564465925592505944209249682185612903 -> 2cFupjhnEsSn59qHXstmK2ffpLv2 |
|||
349694840079 -> ABnLTmg |
|||
3529059230209907258589 -> 3SEo3LWLoPntC |
|||
1462650772 -> 3EFU7m |
|||
1117661258925082241147681 -> EJDM8drfXA6uyA |
|||
281563422 -> Rt5zm |
|||
</pre> |
|||
=={{header|Visual Basic .NET}}== |
=={{header|Visual Basic .NET}}== |
||
{{trans|C#}} |
{{trans|C#}} |