module Base32

Overview

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!"

Extended Modules

Defined in:

base32.cr
base32/version.cr

Constant Summary

VERSION = "0.1.1"

Instance Method Summary

Instance Method Detail

def decode(data) : Slice(UInt8) #

Decode base32 data, regardless if padded or not


[View source]
def decode_string(data) : String #

Decode base32 data, regardless if padded or not


[View source]
def encode(data, pad : Bool = true) : String #

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


[View source]
def hex_decode(data) : Slice(UInt8) #

Decode base32hex data, regardless if padded or not


[View source]
def hex_decode_string(data) : String #

Decode base32hex data, regardless if padded or not


[View source]
def hex_encode(data, pad : Bool = true) : String #

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


[View source]