SCRU128: Sortable, Clock and Random number-based Unique identifier

SCRU128 ID is yet another attempt to supersede UUID for the users who need
decentralized, globally unique time-ordered identifiers. SCRU128 is inspired by
ULID and KSUID and has the following features:
- 128-bit unsigned integer type
- Sortable by generation time (as integer and as text)
- 25-digit case-insensitive textual representation (Base36)
- 48-bit millisecond Unix timestamp that ensures useful life until year 10889
- Up to 281 trillion time-ordered but unpredictable unique IDs per millisecond
- 80-bit three-layer randomness for global uniqueness
import Scru128
// generate a new identifier object
let x = scru128()
print(x) // e.g. "036Z951MHJIKZIK2GSL81GR7L"
print(x.bytes) // as a 128-bit unsigned integer in big-endian byte array
// generate a textual representation directly
print(scru128String()) // e.g. "036Z951MHZX67T63MQ9XE6Q0J"
See SCRU128 Specification for details.
Add swift-scru128 as a package dependency
To add this library to your Xcode project as a dependency, select File >
Add Packages and enter the package URL:
https://github.com/scru128/swift-scru128
To use this library in a SwiftPM project, add the following line to the
dependencies in your Package.swift file:
.package(url: "https://github.com/scru128/swift-scru128", from: "<version>"),
And, include Scru128
as a dependency for your target:
.target(
name: "<target>",
dependencies: [.product(name: "Scru128", package: "swift-scru128")]
)
License
Licensed under the Apache License, Version 2.0.
See also
SCRU128: Sortable, Clock and Random number-based Unique identifier
SCRU128 ID is yet another attempt to supersede UUID for the users who need decentralized, globally unique time-ordered identifiers. SCRU128 is inspired by ULID and KSUID and has the following features:
See SCRU128 Specification for details.
Add swift-scru128 as a package dependency
To add this library to your Xcode project as a dependency, select File > Add Packages and enter the package URL: https://github.com/scru128/swift-scru128
To use this library in a SwiftPM project, add the following line to the dependencies in your Package.swift file:
And, include
Scru128
as a dependency for your target:License
Licensed under the Apache License, Version 2.0.
See also