Functions

The following functions are available globally.

Base32 Data <-> String

  • Encodes data to base32 string using the standard alphabet.

    Uses the standard base32 alphabet (A-Z, 2-7) as defined in RFC 4648.

    Example:

    let data = Data([1, 2, 3, 4, 5])
    let encoded = base32Encode(data)
    

    Declaration

    Swift

    public func base32Encode(_ data: Data) -> String

    Parameters

    data

    Data to encode

    Return Value

    Base32-encoded string

  • Encodes data to base32 string using the extended hex alphabet.

    Uses the extended hex alphabet (0-9, A-V) as defined in RFC 4648.

    Declaration

    Swift

    public func base32HexEncode(_ data: Data) -> String

    Parameters

    data

    Data to encode

    Return Value

    Base32hex-encoded string

  • Decodes a base32 string to data using the standard alphabet.

    Example:

    if let decoded = base32DecodeToData("AEBAGBA") {
        // Use decoded data
    }
    

    Declaration

    Swift

    public func base32DecodeToData(_ string: String) -> Data?

    Parameters

    string

    Base32-encoded string

    Return Value

    Decoded data, or nil if the string is invalid

  • Decodes a base32hex string to data using the extended hex alphabet.

    Declaration

    Swift

    public func base32HexDecodeToData(_ string: String) -> Data?

    Parameters

    string

    Base32hex-encoded string

    Return Value

    Decoded data, or nil if the string is invalid

Base32 [UInt8] <-> String

  • Encodes a byte array to base32 string using the standard alphabet.

    Declaration

    Swift

    public func base32Encode(_ array: [UInt8]) -> String

    Parameters

    array

    Byte array to encode

    Return Value

    Base32-encoded string

  • Encodes a byte array to base32 string using the extended hex alphabet.

    Declaration

    Swift

    public func base32HexEncode(_ array: [UInt8]) -> String

    Parameters

    array

    Byte array to encode

    Return Value

    Base32hex-encoded string

  • Decodes a base32 string to a byte array using the standard alphabet.

    Declaration

    Swift

    public func base32Decode(_ string: String) -> [UInt8]?

    Parameters

    string

    Base32-encoded string

    Return Value

    Decoded byte array, or nil if the string is invalid

  • Decodes a base32hex string to a byte array using the extended hex alphabet.

    Declaration

    Swift

    public func base32HexDecode(_ string: String) -> [UInt8]?

    Parameters

    string

    Base32hex-encoded string

    Return Value

    Decoded byte array, or nil if the string is invalid

BDouble more Operators