https://github.com/sqids/sqids-julia
Official Julia port of Sqids. Generate short unique IDs from numbers.
https://github.com/sqids/sqids-julia
hashids id id-generator julia julia-language julialang short-id short-url sqids uid unique-id unique-id-generator
Last synced: about 7 hours ago
JSON representation
Official Julia port of Sqids. Generate short unique IDs from numbers.
- Host: GitHub
- URL: https://github.com/sqids/sqids-julia
- Owner: sqids
- License: mit
- Created: 2023-06-24T15:37:16.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-09-10T02:05:57.000Z (about 2 years ago)
- Last Synced: 2025-03-24T09:52:56.704Z (7 months ago)
- Topics: hashids, id, id-generator, julia, julia-language, julialang, short-id, short-url, sqids, uid, unique-id, unique-id-generator
- Language: Julia
- Homepage: https://sqids.org/julia
- Size: 36.1 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# [Sqids.jl](https://sqids.org/julia)
[](https://github.com/sqids/sqids-julia/actions)
Sqids (pronounced "squids") is a small library that lets you generate YouTube-looking IDs from numbers. It's good for link shortening, fast & URL-safe ID generation and decoding back into numbers for quicker database lookups.
## Getting started
Install Sqids via (on the Julia REPL):
```julia
julia> ] # enter Pkg REPL-modepkg> add Sqids
```## Examples
Start using Sqids:
```julia
using Sqids
```Simple encode & decode:
```julia
config = Sqids.configure()
id = Sqids.encode(config, [1, 2, 3]) #> "86Rf07"
numbers = Sqids.decode(config, id) #> [1, 2, 3]
```Randomize IDs by providing a custom alphabet:
```julia
config = Sqids.configure(alphabet="FxnXM1kBN6cuhsAvjW3Co7l2RePyY8DwaU04Tzt9fHQrqSVKdpimLGIJOgb5ZE")
id = Sqids.encode(config, [1, 2, 3]) #> "B4aajs"
numbers = Sqids.decode(config, id) #> [1, 2, 3]
```Enforce a *minimum* length for IDs:
```julia
config = Sqids.configure(minLength=10)
id = Sqids.encode(config, [1, 2, 3]) #> "86Rf07xd4z"
numbers = Sqids.decode(config, id) #> [1, 2, 3]
```Prevent specific words from appearing anywhere in the auto-generated IDs:
```julia
config = Sqids.configure(blocklist=["word1","word2"])
id = Sqids.encode(config, [1, 2, 3]) #> "86Rf07"
numbers = Sqids.decode(config, id) #> [1, 2, 3]
```### Julia-specific
If `strict=false` is set when configuring, it enables handling of limitless values using `Int128` or `BigInt`, integer types larger than 64 bits.
```julia
config = Sqids.configure(strict=false) # not-strict mode
id = Sqids.encode(config, Int128[9223372036854775808]) #> "pXFNc5r689z6"
numbers = Sqids.decode(config, id) #> Int128[9223372036854775808]
```Note that while this setting allows for automatic type selection of the decoded value, it may cause type instability and minor performance slowdowns.
## Notes
- **Do not encode sensitive data.** These IDs can be easily decoded.
- **Default blocklist is auto-enabled.** It's configured for the most common profanity words. Create your own custom list by using the `blocklist` parameter, or pass an empty array to allow all words.
- Read more at## License
[MIT](LICENSE)