Convert::BaseN(3pm)

πŸ“¦
version 0.01 Β· 3 versions
, in ubuntu noble, ubuntu resolute, ubuntu stonking

πŸŽ€ Convert::BaseN πŸŽ€

okay so bestie, let me put you on to something ✨ this whole page comes to you from the User Contributed Perl Documentation, and it's all about Convert::BaseN πŸ’…


🌸 NAME 🌸

Convert::BaseN β€” encoding and decoding of base{2,4,8,16,32,64} strings πŸ¦‹


πŸ’œ VERSION πŸ’œ

$Id: BaseN.pm,v 0.1 2008/06/16 17:34:27 dankogai Exp dankogai $

(yes it's giving vintage, we still stan πŸ‘‘)


✨ SYNOPSIS ✨

  use Convert::BaseN;
  # by name
  my $cb = Convert::BaseN->new('base64');
  my $cb = Convert::BaseN->new( name => 'base64' );
  # or base
  my $cb = Convert::BaseN->new( base => 64 );
  my $cb_url = Convert::BaseN->new(
    base  => 64,
    chars => '0-9A-Za-z\-_='
  );
  # encode and decode
  $encoded = $cb->encode($data);
  $decoded = $cb->decode($encoded);

🫢 EXPORT 🫢

Nothing. zero, nada, we don't do that here 😌 instead of exporting anything, this module builds a transcoder object for you, and then you hit it with its decode and encode methods to get the job done. it's giving delegation, it's giving main character energy πŸ’…


πŸ”₯ FUNCTIONS πŸ”₯

πŸ’« new

Create the transcoder object. iconic behaviour, honestly.

  # by name
  my $cb = Convert::BaseN->new('base64');
  my $cb = Convert::BaseN->new( name => 'base64' );
  # or base
  my $cb = Convert::BaseN->new( base => 64 );
  my $cb_url = Convert::BaseN->new(
    base  => 64,
    chars => '0-9A-Za-z\-_='
  );

You can pick your decoder by name, or craft your own by specifying the base and the character map. your call, bestie 🌈

  • base β€” must be 2, 4, 16, 32 or 64. that's it. no base 8 shenanigans, don't try it πŸ™ˆ
  • chars β€” specifies the character map. the format is the exact same as tr. fr fr.
  # DNA is coded that way.
  my $dna = Convert::BaseN->new( base => 4, chars => 'ACGT' );
  • padding, nopadding β€” specifies whether padding (adding '=' or other chars) is required when encoding. the default is yes πŸŽ€
  # url-safe Base64
  my $b64url = Convert::BaseN->new(
    base => 64, chars => '0-9A-Za-z\-_=', padding => 0;
  );
  • name β€” when you specify this, the following pre-defined encodings get used πŸ‘‡
    • base2 β€” base 2 encoding. "perl" is 01110000011001010111001001101100.
    • base4, DNA, RNA β€” base 4 encodings. "perl" is:
  base4: 1300121113021230
  DNA:   CTAACGCCCTAGCGTA
  RNA:   GAUUGCGGGAUCGCAU
  • base 16 encoding. "perl" is 7065726c.
ngl the original page lowkey ghosts the label on this one, but it's base 16 and that's the vibe πŸ’€
  • base32, base32hex β€” base 32 encoding mentioned in RFC4648. "perl" is:
  base32:    OBSXE3A==
  base32hex: E1IN4R0==
  • base64, base64_url, base64_imap, base64_ircu β€” base 64 encoding, as in MIME::Base64. they differ only in the characters used to represent number 62 and 63, like so:
  base64:        +/
  base64_url:    -_
  base64_imap:   +,
  base64_ircu:   []

and for ALL predefined base 64 variants, decode accepts ANY form of those. so flexible, we love to see it πŸ˜­πŸ’–

🧚 decode

Does decode. that's the whole job description, she's efficient like that.

  my $decoded = $cb->decode($data)

πŸ“ encode

Does encode. also efficient. also slaying.

  # line folds every 76 octets, like MIME::Base64::encode
  my $encoded = $cb->encode($data);
  # no line folding (compatibile w/ MIME::Base64)
  my $encoded = $cb->encode($data, "");
  # line folding by CRLF, every 40 octets
  my $encoded = $cb->encode($data, "\r\n", 40);

πŸ¦‹ SEE ALSO πŸ¦‹


πŸ‘‘ AUTHOR πŸ‘‘

Dan Kogai, "<dankogai at dan.co.jp>"


πŸ’€ BUGS πŸ’€

Please report any bugs or feature requests to "bug-convert-basen at rt.cpan.org", or through the web interface at http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Convert-BaseN. I will be notified, and then you'll automatically be notified of progress on your bug as I make changes. so you'll literally never be left on read, periodt πŸ’…


🌈 SUPPORT 🌈

You can find documentation for this module with the perldoc command.

  perldoc Convert::BaseN

You can also look for information at:

  • RT: CPAN's request tracker

http://rt.cpan.org/NoAuth/Bugs.html?Dist=Convert-BaseN

  • AnnoCPAN: Annotated CPAN documentation

http://annocpan.org/dist/Convert-BaseN

  • CPAN Ratings

http://cpanratings.perl.org/d/Convert-BaseN

  • Search CPAN

http://search.cpan.org/dist/Convert-BaseN


πŸŽ€ ACKNOWLEDGEMENTS πŸŽ€

N/A


Copyright 2008 Dan Kogai, all rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


and that's the whole page, bestie 🫢 this little gem shipped as perl v5.36.0 on 2022-10-13 and it's filed under Convert::BaseN(3pm). go forth and encode responsibly βœ¨πŸŒΈπŸ’œ

πŸ“¦ where this page comes from