https://github.com/junker/hashids
Common Lisp system to generate YouTube-like hashes from one or many numbers
https://github.com/junker/hashids
common-lisp hash hashids
Last synced: 4 months ago
JSON representation
Common Lisp system to generate YouTube-like hashes from one or many numbers
- Host: GitHub
- URL: https://github.com/junker/hashids
- Owner: Junker
- License: mit
- Created: 2023-12-20T06:23:24.000Z (over 1 year ago)
- Default Branch: master
- Last Pushed: 2024-02-26T13:25:24.000Z (over 1 year ago)
- Last Synced: 2025-01-01T01:45:38.834Z (6 months ago)
- Topics: common-lisp, hash, hashids
- Language: Common Lisp
- Homepage:
- Size: 7.81 KB
- Stars: 2
- Watchers: 4
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Hashids
Common Lisp system to generate YouTube-like hashes from one or many numbers.
Use hashids when you do not want to expose your database ids to the user.## Installation
This system can be installed from [UltraLisp](https://ultralisp.org/) like this:
```lisp
(ql-dist:install-dist "http://dist.ultralisp.org/"
:prompt nil)
(ql:quickload "hashids")
```## Usage
```common-lisp
(defvar *id* (hashids:encode 1 2 3)) ; o2fXhV
(hashids:decode *id*) ; (1 2 3)
```Making your output ids unique:
```common-lisp
(let ((hashids:*salt* "My Project"))
(hashids:encode 1 2 3)) ; Z4UrtW(let ((hashids:*salt* "My Other Project"))
(hashids:encode 1 2 3)) ; gPUasb
```Use padding to make your output ids longer:
```common-lisp
(hashids:encode 1) ; jR(let ((hashids:*min-hash-length* 10))
(hashids:encode 1)) ; VolejRejNm
```Using a custom alphabet:
```common-lisp
(let ((hashids:*alphabet* "abcdefghijklmnopqrstuvwxyz"))
(hashids:encode 1 2 3)) ; mdfphx
```## Curse words! #$%@
This code was written with the intent of placing the output ids in visible places, like the URL. Therefore, the algorithm tries to avoid generating most common English curse words by generating ids that never have the following letters next to each other:
```
c, f, h, i, s, t, u
```