Bitcoin/address validation: Difference between revisions
Content added Content deleted
m (→{{header|Perl}}: slight simplification) |
m (→{{header|Perl}}: @hash is a terrible variable name) |
||
Line 22: | Line 22: | ||
use Digest::SHA qw(sha256); |
use Digest::SHA qw(sha256); |
||
my $value = decode shift; |
my $value = decode shift; |
||
my @ |
my @byte; for (1 .. 25) { push @byte, $value % 256; $value /= 256 } |
||
@ |
@byte = reverse @byte; |
||
die unless join('', map { chr } @ |
die unless join('', map { chr } @byte[21..24]) eq |
||
substr sha256(sha256 pack 'C*', @ |
substr sha256(sha256 pack 'C*', @byte[0..20]), 0, 4; |
||
}</lang> |
}</lang> |
||