|
NAMEEncode::Base32::Crockford - encode/decode numbers using Douglas Crockford's Base32 EncodingVERSIONversion 2.112991DESCRIPTIONDouglas 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. SYNOPSISuse 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); METHODSbase32_encodeprint base32_encode(1234); # prints "16J" Encode a base 10 number. Will die on inappropriate input. base32_encode_with_checksumprint 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. base32_decodeprint 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. base32_decode_with_checksumprint 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". normalizemy $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:
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. AUTHORGraham Barr <gbarr@cpan.org>CREDITSThe original module was written by Earle Martin <hex@cpan.org>COPYRIGHTThis code is free software; you can redistribute it and/or modify it under the same terms as Perl itself.REPOSITORYThe git repository for this distribution is available at <https://github.com/gbarr/Encode-Base32-Crockford>
Visit the GSP FreeBSD Man Page Interface. |