module

Base32

The Base32 module provides for the encoding (encode, hex_encode) and decoding (decode, decode_string, hex_decode, hex_decode_string) of binary data using a Base32 representation as defined in RFC 4648.

Examples

A simple encoding and decoding:

require "base32"

Base32.encode("Hello World!")        # => "JBSWY3DPEBLW64TMMQQQ===="
Base32.encode("Hello World!", false) # => "JBSWY3DPEBLW64TMMQQQ"

Base32.decode_string("JBSWY3DPEBLW64TMMQQQ====") # => "Hello World!"
Base32.decode_string("JBSWY3DPEBLW64TMMQQQ")     # => "Hello World!"

Constants

VERSION = "0.1.1"

Instance methods

decode(data) : Slice(UInt8)

Decode base32 data, regardless if padded or not

Source
decode_string(data) : String

Decode base32 data, regardless if padded or not

Source
encode(data, pad : Bool = true) : String

Encode data as base32 with padding, or without if pad = false

Source
hex_decode(data) : Slice(UInt8)

Decode base32hex data, regardless if padded or not

Source
hex_decode_string(data) : String

Decode base32hex data, regardless if padded or not

Source
hex_encode(data, pad : Bool = true) : String

Encode data as base32hex with padding, or without if pad = false

Source