A small Swift library that provides explicit, predictable Base64 encoding and decoding.
In real-world systems, Base64 handling tends to show up at boundaries: authentication flows, cryptographic payloads, API contracts, persistence layers.
In many codebases, this logic ends up:
- duplicated across projects
- mixed with unrelated string manipulation
- loosely validated or inconsistently encoded
- difficult to reason about at call sites
This library exists to make Base64 handling:
- explicit
- well-typed
- easy to audit
- hard to misuse
It pulls this logic into a single, focused abstraction that can be reused confidently across projects.
- A lightweight Swift wrapper around Base64 encoding and decoding
- Focused on clarity and correctness, not cleverness
- Designed to be used at system boundaries
- Small enough to read and understand end-to-end
- Convenience extensions that hide failure
- Silent coercion of invalid input
- Global helpers scattered across
StringorData - Over-generalised encoding utilities
If a value cannot be decoded, the API makes that explicit.
let encoded = EncodedBase64("hello world")
let decoded = try encoded.decodedString()The intent is visible at the call site: you are working with a Base64-encoded value, not an arbitrary string.
- Explicit representation Encoded values are modelled intentionally, not inferred.
- Fail clearly Invalid input is surfaced immediately rather than silently ignored.
- Small surface area The library does one thing and stays out of the way.
- Production-oriented Suitable for authentication, cryptography, and API boundary code.
Use this library when:
- Base64 values are part of your domain or protocol
- correctness matters more than convenience
- you want to make encoding/decoding intent obvious in code
If you only need a one-off helper, this may be more structure than you need.
This logic was originally extracted from production WebAuthn-related code and simplified for general reuse. It remains intentionally minimal.
A small Swift library that provides explicit, predictable Base64 encoding and decoding.
Designed for production codebases that need to handle Base64 safely and consistently without scattering string utilities across the app.
In real-world systems, Base64 handling tends to show up at boundaries: authentication flows, cryptographic payloads, API contracts, persistence layers.
In many codebases, this logic ends up:
- duplicated across projects
- mixed with unrelated string manipulation
- loosely validated or inconsistently encoded
- difficult to reason about at call sites
This library exists to make Base64 handling:
- explicit
- well-typed
- easy to audit
- hard to misuse
It pulls this logic into a single, focused abstraction that can be reused confidently across projects.
- A lightweight Swift wrapper around Base64 encoding and decoding
- Focused on clarity and correctness, not cleverness
- Designed to be used at system boundaries
- Small enough to read and understand end-to-end
- Convenience extensions that hide failure
- Silent coercion of invalid input
- Global helpers scattered across
StringorData - Over-generalised encoding utilities
If a value cannot be decoded, the API makes that explicit.
let encoded = EncodedBase64("hello world")
let decoded = try encoded.decodedString()The intent is visible at the call site: you are working with a Base64-encoded value, not an arbitrary string.
- Explicit representation Encoded values are modelled intentionally, not inferred.
- Fail clearly Invalid input is surfaced immediately rather than silently ignored.
- Small surface area The library does one thing and stays out of the way.
- Production-oriented Suitable for authentication, cryptography, and API boundary code.
Use this library when:
- Base64 values are part of your domain or protocol
- correctness matters more than convenience
- you want to make encoding/decoding intent obvious in code
If you only need a one-off helper, this may be more structure than you need.
This library was extracted and adapted from Base64 handling logic originally implemented in webauthn-swift-models.
The original project implements parts of the WebAuthn specification in Swift. This package isolates and generalises the Base64-related components for reuse in non-WebAuthn contexts.
Credit and thanks to the original authors and contributors.