Swiftpack.co - skytoup/shortuuid as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
skytoup/shortuuid
A generator library for concise, unambiguous and URL-safe UUIDs.
.package(url: "https://github.com/skytoup/shortuuid.git", from: "1.0.1")

ShortUUID

A Swift library that generates concise, unambiguous, URL-safe UUIDs. Based on and compatible with the Python library shortuuid and Go library shortuuid.

Usage

import ShortUUID

let su = ShortUUID()

You can then generate a short UUID

su.uuid() // vytxeTZskVKR7C7WgdSP3d

If you prefer a version 5 UUID, you can pass a name (DNS or URL) to the call and it will be used as a namespace (uuid.NAMESPACE_DNS or uuid.NAMESPACE_URL) for the resulting UUID:

su.uuid(name: "example.com") // wpsWLdLt9nscn2jbTD3uxe
su.uuid(name: "http://example.com") // c8sh5y9hdSMS6zVnrvf53T

You can also generate a cryptographically secure random string (using os.urandom(), internally) with:

su.random(length: 22) // RaF56o2r58hTKT7AYS9doj

To see the alphabet that is being used to generate new UUIDs:

su.alphabet // 23456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz

If you want to use your own alphabet to generate UUIDs

su.alphabet = "aaaaabcdefgh1230123"
su.uuid() // 0agee20aa1hehebcagddhedddc0d2chhab3b

shortuuid will automatically sort and remove duplicates from your alphabet to ensure consistency:

su.alphabet // 0123abcdefgh

License

MIT

GitHub

link
Stars: 1
Last commit: 3 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Submit a free job ad (while I'm testing this). The analytics numbers for this website are here.

Release Notes

1.0.1
3 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics