Codebase list libcryptx-perl / 34a3f54
bug: decode_b58b + invalid input Karel Miko 6 years ago
2 changed file(s) with 4 addition(s) and 2 deletion(s). Raw diff Collapse all Expand all
6363
6464 my $default = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuv";
6565 if (defined $alphabet) {
66 return undef if $alphabet !~ /^[a-zA-Z0-9]{58}$/;
66 return undef if $alphabet !~ /^[a-zA-Z0-9]{58}$/ || $base58 !~ /^[$alphabet]+$/;
6767 eval "\$base58 =~ tr/$alphabet/$default/"; # HACK: https://stackoverflow.com/questions/11415045/using-a-char-variable-in-tr
6868 return undef if $@;
6969 }
00 use strict;
11 use warnings;
2 use Test::More tests => 679;
2 use Test::More tests => 680;
33
44 use Crypt::Misc qw( encode_b64 decode_b64
55 encode_b64u decode_b64u
142142 is(unpack("H*", decode_b32z(encode_b32z($b))), $h);
143143 is(unpack("H*", decode_b32c(encode_b32c($b))), $h);
144144 }
145
146 is(decode_b58b("111OIl0"), undef, "bug: decode_b58b + invalid input");