Structures

The following structures are available globally.

  • The Base32 struct contains methods to encode and decode data using the Base 32 encoding as defined by RFC 4648.

    The API supports both alphabets defined in the specification for encoding and decoding data:

    1. The Base 32 Alphabet (see RFC 4648 Section 6)
    2. The “Extended Hex” Base 32 Alphabet (see RFC 4648 Section 7)

    The API only supports the encoding and decoding of strings and no other data types. All the inputs are validated and the API will throw exceptions instead of ignoring illegal input.

    All methods are static so no instance of the Base32 struct needs to be created.

    Examples:

    let encoded = Base32.encode(string: "foobar")
    print(encoded) // prints "MZXW6YTBOI======"
    
    if let decoded = try? Base32.decode(string: encoded) {
        print(decoded) // prints "foobar"
    }
    

    Note

    Encoding and decoding methods are not optimized and might perform badly. Use another Swift package if performance is a primary concern.

    Warning

    This API is still under development. APIs are subject to change and error. Do not use in production.
    See more

    Declaration

    Swift

    public struct Base32