Base32Encoder is a pure Swift library that encodes Data to a Base32 String
Encodes data as per the [RFC 3548] specification for Base32 data encodings.
This library was written for a project that required encoding of small data packets and to learn bit bashing. This means the code is written for learning and has not been optimized for elegance or performance.
Simply add the requirement to your Cartfile:
github "markrenaud/Base32Encoder"
Copy Base32.swift to your project
If the Base32Encoder was installed as a library, you must import it (this can be skipped if it was manually added to your project).
import import Base32Encoder
You can then encode data and (optionally pad as per RFC 3548 2.2 - Padding of encoded data
let data = "hi".data(using: .ascii)!
let base32 = Base32.encode(data: data) // = "NBUQ"
let base32padded = Base32.encode(data: data, padding: true) // = "NBUQ===="Or you can use the Data extension
let base32 = data.base32String(padded: true) // = "NBUQ===="This project is licensed under the MIT license. See the LICENCE file for more info.