NAME

App::CrockfordBase32Utils - Utilities related to Crockford's Base 32 encoding

VERSION

This document describes version 0.002 of App::CrockfordBase32Utils (from Perl distribution App-CrockfordBase32Utils), released on 2026-01-19.

DESCRIPTION

This distribution contains the following CLIs:

Keywords: base32, base 32, crockford's base 32

FUNCTIONS

cfbase32_decode

Usage:

cfbase32_decode(%args) -> [$status_code, $reason, $payload, \%result_meta]

Decode Crockford's Base32 encoding.

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • str => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

cfbase32_encode

Usage:

cfbase32_encode(%args) -> [$status_code, $reason, $payload, \%result_meta]

Encode string to Crockford's Base32 encoding.

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • str => str

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

cfbase32_rand

Usage:

cfbase32_rand(%args) -> [$status_code, $reason, $payload, \%result_meta]

Generate one or more Crockford Base 32 numbers.

Examples:

  • Generate 5 random numbers from 12 digits each, first digit(s) can be 0:

    cfbase32_rand(len => 12, num => 35);

    Result:

    [
      200,
      "OK",
      [
        "S19WAC3HG0RW",
        "DBD7KC1Z4R2S",
        "FNJE31GGWXHC",
        "5Y8BTWC4V387",
        "AQK25BFF9J2T",
        "J1X3YT947R2K",
        "3R4GFCKM36CC",
        "SK3X0X75SEMP",
        "15F8XWJ6SK61",
        "9TP7F5TCCJKF",
        "4RWYJX2PKJ3Q",
        "WCP48G44QQ69",
        "XCKAN0WSQ193",
        "EG3SCKG3H7E9",
        "X6NNHSMXHYSP",
        "884AZ0BBZRZ8",
        "GEFT3K6N5Y4P",
        "K8J6DBJG60FF",
        "T4ZPJRFPT8QQ",
        "HPTG7CJ4EZTB",
        "Z3V9PPW27K5Z",
        "YB3MQP9NVTB2",
        "Z04PXT0ZW58Z",
        "19G8YRFPNFBC",
        "03J3DT1813ZR",
        "9RWQVT6F1JXM",
        "EP58YN26H7VY",
        "A892VRX7FR6N",
        "PFAP10YVEM4V",
        "W2EAP0F9SZH4",
        "83P4TPXVEEZF",
        "NEC8VT2S7B78",
        "3RR7D7HWKF6P",
        "VYREC7Q7XT62",
        "C2WHFKM3FYMJ",
      ],
      {},
    ]
  • Generate 5 random numbers from 12 digits each, first digit(s) CANNOT be 0:

    cfbase32_rand(len => 12, num => 35, zero_prefix => 0);

    Result:

    [
      200,
      "OK",
      [
        "1GKRJ5V7GSRS",
        "HNA0SBZYSJRF",
        "YVVNS31GAWSZ",
        "S2G0FGM6HGAB",
        "VZ4M8K2Y6EQD",
        "S2KNNJSBP412",
        "YQSEX35KJ3JR",
        "T0CGK19AXF13",
        "YNDHTFQCH8NB",
        "G1N75MYAC0V8",
        "77N3N0DPB4C2",
        "X874R7QT425Y",
        "Z0YYYK3X9Q6C",
        "Q3GYF41BFRZG",
        "49P8QC6Z28QS",
        "NR700A3SA79M",
        "Q3N82TWHM3H4",
        "92EN559RSSR4",
        "VSDH8B1SQRFF",
        "BR1WQX6GGRK8",
        "C1R69F0K196H",
        "G7AZZVN7DF6A",
        "G9V8BSMF0205",
        "VM6VGG8VMXMK",
        "8W2VBFFN1ZZY",
        "1K6N6Y997XPQ",
        "5H5MWPN8VTEW",
        "3BC87J5W3M1N",
        "3EYXJGFYBCQS",
        "BHR03PMWYZ7Q",
        "K7NT926VG8JV",
        "K4PC04BZ2DPM",
        "J34K0VBWQ3QZ",
        "J24C00NMT8A2",
        "8R3PJ910J6CN",
      ],
      {},
    ]

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • len => int

    Specify how many number of digits to generate for a number.

    Note that the first digit can still be 0 unless zero_prefix is set to false.

  • max_base32 => str

    (No description)

  • max_int => int

    (No description)

  • max_len => int

    Specify how many maximum number of digits to generate.

    Note that the first digit can still be 0 unless zero_prefix is set to false.

  • min_base32 => str

    (No description)

  • min_int => int

    (No description)

  • min_len => int

    Specify how many minimum number of digits to generate.

    Note that the first digit can still be 0 unless zero_prefix is set to false.

  • num => uint (default: 1)

    Specify how many numbers to generate.

  • prev_nums_file => filename

    (No description)

  • unique => bool

    Whether to avoid generating previously generated numbers.

  • zero_prefix => bool (default: 1)

    When generating random number of certain length range, whether the first digit is allowed to be zero.

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

cfbase32_to_num

Usage:

cfbase32_to_num(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert Crockford's Base 32 encoding to integer decimal number.

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • strs => array[str]

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

num_to_cfbase32

Usage:

num_to_cfbase32(%args) -> [$status_code, $reason, $payload, \%result_meta]

Convert integer decimal number(s) to Crockford's Base 32 encoding.

This function is not exported by default, but exportable.

Arguments ('*' denotes required arguments):

  • nums => array[int]

    (No description)

Returns an enveloped result (an array).

First element ($status_code) is an integer containing HTTP-like status code (200 means OK, 4xx caller error, 5xx function error). Second element ($reason) is a string containing error message, or something like "OK" if status is 200. Third element ($payload) is the actual result, but usually not present when enveloped result is an error response ($status_code is not 2xx). Fourth element (%result_meta) is called result metadata and is optional, a hash that contains extra information, much like how HTTP response headers provide additional metadata.

Return value: (any)

HOMEPAGE

Please visit the project's homepage at https://metacpan.org/release/App-CrockfordBase32Utils.

SOURCE

Source repository is at https://github.com/perlancar/perl-App-CrockfordBase32Utils.

SEE ALSO

https://www.crockford.com/base32.html

AUTHOR

perlancar <perlancar@cpan.org>

CONTRIBUTING

To contribute, you can send patches by email/via RT, or send pull requests on GitHub.

Most of the time, you don't need to build the distribution yourself. You can simply modify the code, then test via:

% prove -l

If you want to build the distribution (e.g. to try to install it locally on your system), you can install Dist::Zilla, Dist::Zilla::PluginBundle::Author::PERLANCAR, Pod::Weaver::PluginBundle::Author::PERLANCAR, and sometimes one or two other Dist::Zilla- and/or Pod::Weaver plugins. Any additional steps required beyond that are considered a bug and can be reported to me.

COPYRIGHT AND LICENSE

This software is copyright (c) 2026 by perlancar <perlancar@cpan.org>.

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

BUGS

Please report any bugs or feature requests on the bugtracker website https://rt.cpan.org/Public/Dist/Display.html?Name=App-CrockfordBase32Utils

When submitting a bug or request, please include a test-file or a patch to an existing test-file that illustrates the bug or desired feature.