base32(3tcl)

πŸ“¦
version 2.0 Β· 2 versions
, in debian trixie, ubuntu questing, ubuntu resolute, ubuntu stonking

okay bestie, gather round πŸ’– you've stumbled into base32, a lil Tcl library page (manual section 3tcl) and honestly? it's giving "small but mighty." it does exactly one thing and it does it flawlessly: turning strings into standard base32 and back again. no cap. let's get into it ✨


🌸 NAME 🌸

base32 β€” the standard base32 encoding, but make it Tcl πŸŽ€


πŸ¦‹ SYNOPSIS πŸ¦‹

package require Tcl 8.5 9

package require base32::core ?0.2?

package require base32 ?0.2?

::base32::encode string

::base32::decode estring

like. that's the whole vibe check right there. two commands, one job, zero drama πŸ’…


✨ DESCRIPTION ✨

so basically this package hands you the commands to encode strings into and decode strings out of the standard base32 encoding, exactly as specified in RFC 3548. that's it, that's the whole personality. and yet. iconic. πŸ‘‘


πŸ’œ API πŸ’œ

  • ::base32::encode string β€” bestie, this one takes the string you gave it, encodes it in base32, and hands the encoded string right back to you as the result. heads up tho: the result may be padded with the character = to signal a partial encoding at the end of the input string. so if you see a stray = at the tail, that's not a bug, that's the padding doing its lil thing πŸ™ˆ
  • ::base32::decode estring β€” this one takes estring and decodes it, operating on the assumption that it is a valid base32 encoded string. the decoded result gets returned as the result of the command. fr fr.

quick note tho, because it matters: the encoder only ever generates uppercase characters, but this decoder? she's flexible. she accepts input in lowercase too. slay πŸ’…

now the serious part, because the command is not playing games: it will always throw an error whenever it runs into conditions that signal some type of bogus input. specifically, if:

  1. the input contains characters which are not valid output of a base32 encoder,
  2. the length of the input is not a multiple of eight,
  3. padding appears not at the end of input, but in the middle,
  4. the padding has not of length six, four, three, or one characters.
so yeah. bad input = error, every single time. no silent nonsense, no "eh close enough." she said boundaries. 🚧

🌈 CODE MAP 🌈

here's the code map used to convert 5-bit sequences, with the numeric id of the bit sequences chillin' on the left and the character used to encode it on the right. and yes, you read that right β€” the characters "0" and "1" are not used by the encoding. that's on purpose, bestie: those two can be easily confused with "O", "o" and "l" (L). big brain move, honestly. 🧠✨

         0 A    9 J   18 S   27 3
         1 B   10 K   19 T   28 4
         2 C   11 L   20 U   29 5
         3 D   12 M   21 V   30 6
         4 E   13 N   22 W   31 7
         5 F   14 O   23 X
         6 G   15 P   24 Y
         7 H   16 Q   25 Z
         8 I   17 R   26 2

😭 BUGS, IDEAS, FEEDBACK 😭

okay so, real talk: this document, and the package it describes, will undoubtedly contain bugs and other problems. that's just how it is, no shame. please report such in the category base32 of the Tcllib Trackers at [http://core.tcl.tk/tcllib/reportlist]. and please also report any ideas for enhancements you may have for either the package and/or the documentation β€” they wanna hear it, fr. 🫢

when proposing code changes, please provide unified diffs, i.e. the output of diff -u.

note further that attachments are strongly preferred over inlined patches. attachments can be made by going to the Edit form of the ticket immediately after its creation, and then using the left-most button in the secondary navigation bar. iykyk. πŸ’…


πŸŽ€ KEYWORDS πŸŽ€

base32, rfc3548


πŸ‘‘ CATEGORY πŸ‘‘

Text processing


Public domain


and that's the whole page, bestie πŸ¦‹ it's tcllib, version 0.2, and it's all yours β€” public domain, go wild, you're the main character of this manpage now. mwah πŸ’–βœ¨

πŸ“¦ where this page comes from