iCyberon / pg_hashids

Short unique id generator for PostgreSQL, using hashids
MIT License
280 stars 24 forks source link

Custom Alphabet Support #2

Closed iCyberon closed 7 years ago

iCyberon commented 7 years ago

Requested #1

somebee commented 7 years ago

I'd be fine with both definiting it once, and with setting it on each call. Whatever is the easiest :)

iCyberon commented 7 years ago

Fixed by https://github.com/iCyberon/pg_hashids/commit/98d0311755fdb29067dc21fe56c03fc9ab054cda

SELECT hash_encode(3);
SELECT hash_encode(3, 'salt');
SELECT hash_encode(3, 'salt', 4);
SELECT hash_decode('mw2k', 'salt', 4);

SELECT id_encode(3);
SELECT id_encode(3, 'salt');
SELECT id_encode(3, 'salt', 4);
SELECT id_decode('mw2k','salt', 4);

SELECT id_encode(3, 'salt', 4, 'abcdefghijABCDxFGHIJ1234567890');
SELECT id_decode('830a', 'salt', 4, 'abcdefghijABCDxFGHIJ1234567890');