Convert::Base32(3pm)

✨ Convert::Base32 ✨

okay bestie, so this is Convert::Base32 β€” a lil Perl module from the User Contributed Perl Documentation crew that does exactly one thing and does it gorgeously: encoding and decoding of base32 strings. πŸ’…


🌸 NAME 🌸

Convert::Base32 β€” encoding and decoding of base32 strings πŸ’–


πŸŽ€ SYNOPSIS πŸŽ€

use Convert::Base32;

$encoded = encode_base32("\x3a\x27\x0f\x93");
$decoded = decode_base32($encoded);

look at her. two functions. no drama. iconic. ✨


πŸ¦‹ DESCRIPTION πŸ¦‹

So this module hands you the functions to convert a string from / to Base32 encoding, and specifically the Base32 encoding that's specified in the RACE internet-draft. 🧚

The whole point of Base32 encoding? It's designed to encode non-ASCII characters in DNS-compatible host name parts. So like, it's the girlboss of encoding schemes when your DNS host names need to play nice but your characters are out here being un-ASCII. πŸ’…

Wanna read the whole lore? See http://tools.ietf.org/html/draft-ietf-idn-race-03 for more details, no cap. πŸ“–


πŸ’œ FUNCTIONS πŸ’œ

Following functions are provided β€” and like MIME::Base64, they are all sitting pretty in the @EXPORT array. So they get exported to you by default, bestie. See Exporter for details. 🫢

encode_base32($str)

Encode data by calling the encode_base32() function. This function takes a string of bytes to encode and returns the encoded base32 string. That's it. That's the whole job. ⭐

decode_base32($str)

Decode a base32 string by calling the decode_base32() function. This function takes a string to decode and returns the decoded string. 🌈

⚠️ okay but listen β€” this function might throw the exceptions such as Data contains non-base32 characters, Length of data invalid and Padding bits at the end of output buffer are not all zero. So like, wrap her in an eval if you're feeling fragile. 😭

and here's the lil quirk that makes her different πŸ‘‡

decode_base32 differs from the specification in that upper case letters are treated as their lower case equivalent rather than producing an error. so she's forgiving like that. lowkey generous fr fr. πŸ’–


πŸ‘‘ AUTHOR πŸ‘‘

  • Tatsuhiko Miyagawa <miyagawa@bulknews.net>
  • Eric Brine <ikegami@adaelis.com>

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself. πŸŽ€


πŸ”₯ SEE ALSO πŸ”₯


and that's the whole vibe check bestie β€” this page ships with perl v5.36.0, dated 2022-10-13, converted for you by the User Contributed Perl Documentation fairies. go forth and base32 your little heart out, i'm obsessed πŸ’–βœ¨πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from