UUIDB64URL is a simple Swift Package that extends the UUID
class to add support for decoding UUIDs from and encoding UUIDs to base64url (RFC 4648) strings.
To integrate UUIDB64URL into your Xcode project using Swift Package Manager, follow these steps:
- Open your target in Xcode.
- Go to "File" -> "Add Package Dependencies...".
- In the search bar, enter
https://github.com/gossamr/swift-uuid-base64url.git
and click "Add Package".
Import the UUIDB64URL package in your Swift files:
import UUIDB64URL
To encode a UUID
instance to a base64url string, use the following accessor:
let uuid = UUID()
let base64urlString = uuid.base64url
print("UUID encoded as Base64url String: \(base64urlString)")
To decode a base64url string back to a UUID
instance, use the following initializer:
let recovered = UUID(base64url: base64urlString) // returns UUID?, as decoding can fail
UUIDB64URL is released under the MIT license. See LICENSE for more information.
Contributions are welcome! Please open an issue or submit a pull request to improve this package.