Bitcoin/public point to address: Difference between revisions

(→‎{{header|Perl 6}}: Use different modules in place of deprecated SSL::Digest.)
Line 426:
{{out}}
<pre>6UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM</pre>
 
=={{header|Phix}}==
<lang Phix>include builtins\sha256.e
include builtins\ripemd160.e
 
constant b58 = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
 
function base58(string s)
string out = ""
if length(s)!=25 then ?9/0 end if
for n=1 to 34 do
integer c = 0
for i=1 to 25 do
c = c*256+s[i]
s[i] = floor(c/58)
c = mod(c,58)
end for
out &= b58[c+1]
end for
if out[$]='1' then
for i=length(out)-1 to 1 by -1 do
if out[i]!='1' then
out = out[1..i+1]
exit
end if
end for
end if
return reverse(out)
end function
function rev4(string s)
string res = ""
for i=1 to length(s)-3 by 4 do
for j=i+3 to i by -1 do
res &= s[j]
end for
end for
return res
end function
 
function coin_encode(string x, y)
if length(x)!=32
or length(y)!=32 then
return "bad public point string"
end if
string s = "\x04" & x & y
string rmd = '\0'&ripemd160(rev4(sha256(s)),false)
rmd &= rev4(sha256(rev4(sha256(rmd))))[1..4]
string res = base58(rmd)
return res
end function
?coin_encode(x"50863AD64A87AE8A2FE83C1AF1A8403CB53F53E486D8511DAD8A04887E5B2352",
x"2CD470243453A299FA9E77237716103ABC11A1DF38855ED6F2EE187E9C582BA6")</lang>
{{out}}
<pre>
"16UwLL9Risc3QfPqBUvKofHmBQ7wMtjvM"
</pre>
 
=={{header|PicoLisp}}==
7,806

edits