strex: added `detectUrl()`
[iv.d.git] / base58_test / base58_test.d
blob2fe9a1b6db26860f1f959e24831a29144648852f
1 /* Invisible Vector Library
2 * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3 * Understanding is not required. Only obedience.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, version 3 of the License ONLY.
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 module base58_test is aliced;
19 import iv.base58;
20 import iv.vfs.io;
23 void main () {
24 enum keystr = "0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D";
25 immutable ubyte[$] keybin = cast(immutable(ubyte)[])x"0C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D";
26 enum hexstr = "800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D507A5B8D";
27 immutable ubyte[$] bindata = cast(immutable(ubyte)[])x"800C28FCA386C7A227600B2FE50B7CAE11EC86D3BF1FBE471BE89827E19D72AA1D507A5B8D";
28 enum encetha = "5HueCGU8rMjxEXxiPuD5BDku4MkFqeZyd4dZ1jvhTVqvbTLvyTJ";
30 auto checkenc = base58EncodeCheck(0x80, keybin);
31 writeln(checkenc);
32 assert(checkenc == encetha);
34 ubyte pfxbyte;
35 auto dec = base58DecodeCheck(checkenc);
36 writeln(dec[0], "; len=", dec.length);
37 assert(dec[1..$] == keybin[]);
39 auto encdata = base58Encode(bindata);
40 writeln(encdata);
41 assert(encdata == encetha);
43 auto decbin = base58Decode(encdata);
44 writeln(decbin.length);
45 string xst;
46 foreach (immutable ubyte v; decbin[]) { import std.format : format; xst ~= "%02X".format(v); }
47 writeln(xst);
48 writeln(hexstr);
49 assert(xst == hexstr);