Encode-Base58-BigInt

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

NAME
    Encode::Base58::BigInt - Base58 encodings with BigInt

SYNOPSIS
      use Encode::Base58::BigInt;
      my $bigint  = '9235113611380768826';
      my $encoded = encode_base58($bigint);
      my $decoded = decode_base58($short); # decoded is bigint string

DESCRIPTION
    Encode::Base58::BigInt is a base58 encoder/decoder implementation in
    Perl.

    Generated strings excludes confusing characters, "0" and "O" is treated
    as "D", "l" and "I" is treated as "1".

AUTHOR
    cho45 <cho45@lowreal.net>

lib/Encode/Base58/BigInt.pm  view on Meta::CPAN

    }

    $res;
}

sub decode_base58 {
    my $str = shift;
    $str =~ tr/0OlI/DD11/;
    $str =~ $reg or croak "Invalid Base58";

    my $decoded = Math::BigInt->new(0);
    my $multi   = Math::BigInt->new(1);
    my $base    = @$chars;

    while (length $str > 0) {
        my $digit = chop $str;
        $decoded->badd($multi->copy->bmul($map->{$digit}));
        $multi->bmul($base);
    }

    "$decoded";
}

1;
__END__

=head1 NAME

Encode::Base58::BigInt - Base58 encodings with BigInt

=head1 SYNOPSIS

  use Encode::Base58::BigInt;
  my $bigint  = '9235113611380768826';
  my $encoded = encode_base58($bigint);
  my $decoded = decode_base58($short); # decoded is bigint string


=head1 DESCRIPTION

Encode::Base58::BigInt is a base58 encoder/decoder implementation in Perl.

Generated strings excludes confusing characters, "0" and "O" is treated as "D", "l" and "I" is treated as "1".

=head1 AUTHOR



( run in 0.330 second using v1.01-cache-2.11-cpan-0d8aa00de5b )