GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Encode::Base32::Crockford(3) User Contributed Perl Documentation Encode::Base32::Crockford(3)

Encode::Base32::Crockford - encode/decode numbers using Douglas Crockford's Base32 Encoding

version 2.112991

Douglas Crockford describes a Base32 Encoding at <http://www.crockford.com/wrmg/base32.html>. He says: "[Base32 Encoding is] a 32-symbol notation for expressing numbers in a form that can be conveniently and accurately transmitted between humans and computer systems."

This module provides methods to convert numbers to and from that notation.

    use Encode::Base32::Crockford qw(:all); # import all methods

or

    use Encode::Base32::Crockford qw(base32_decode); # your choice of methods
    
    my $decoded = base32_decode_with_checksum("16JD");
    my $encoded = base32_encode_with_checksum(1234);

    print base32_encode(1234); # prints "16J"

Encode a base 10 number. Will die on inappropriate input.

    print base32_encode_with_checksum(1234); # prints "16JD"

Encode a base 10 number with a checksum symbol appended. See the spec for a description of the checksum mechanism. Wraps the previous method so will also die on bad input.

    print base32_decode("16J"); # prints "1234"

    print base32_decode("IO", { mode => "warn"   }); # print "32" but warn
    print base32_decode("IO", { mode => "strict" }); # dies

Decode an encoded number into base 10. Will die on inappropriate input. The function is case-insensitive, and will strip any hyphens in the input (see "normalize()"). A hashref of options may be passed, with the only valid option being "mode". If set to "warn", normalization will produce a warning; if set to "strict", requiring normalization will cause a fatal error.

    print base32_decode_with_checksum("16JD"); # prints "1234"

Decode an encoded number with a checksum into base 10. Will die if the checksum isn't correct, and die on inappropriate input. Takes the same "mode" option as "base32_decode".

    my $string = "ix-Lb-Ko";
    my $clean = normalize($string);

    # $string is now '1X1BK0'.

The spec allows for certain symbols in encoded strings to be read as others, to avoid problems with misread strings. This function will perform the following conversions in the input string:

  • "i" or "I" to 1
  • "l" or "L" to 1
  • "o" or "O" to 0

It will also remove any instances of "-" in the input, which are permitted by the spec as chunking symbols to aid human reading of an encoded string, and uppercase the output.

Graham Barr <gbarr@cpan.org>

The original module was written by Earle Martin <hex@cpan.org>

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

The git repository for this distribution is available at <https://github.com/gbarr/Encode-Base32-Crockford>
2011-10-26 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.