Bitcoin/public point to address: Difference between revisions

Improved D entry
(Added zkl)
(Improved D entry)
Line 101:
 
=={{header|D}}==
Requires the second D module from the SHA-256 task.
{{trans|C}}
{{trans|Go}}
<lang d>import std.stdio, std.algorithm, std.digest.ripemd, sha_256sha_256_2;
 
// A Bitcoin public point.
Line 115:
 
 
/**// Returns a base 58 encoded bitcoin address corresponding to the receiver.
char[] toBase58(ref Address a) pure nothrow @safe {
to the receiver. */
char[] toBase58(ref Address a) pure nothrow {
static immutable symbols = "123456789" ~
"ABCDEFGHJKLMNPQRSTUVWXYZ" ~
Line 127 ⟶ 126:
uint c = 0;
foreach (ref ai; a) {
cimmutable d = (c % symbols.length) * 256 + ai;
ai = cast(ubyte)(cd / symbols.length);
c %= symbols.lengthd;
}
ri = symbols[c % symbols.length];
}