All Projects → andreystepanov → hashids.sql

andreystepanov / hashids.sql

Licence: MIT license
PL/pgSQL implementation of hashids library

Programming Languages

PLpgSQL
1095 projects

Projects that are alternatives of or similar to hashids.sql

shortid
Super short, fully unique, non-sequential and URL-friendly Ids
Stars: ✭ 20 (-50%)
Mutual labels:  id, shortid
tsid-creator
A Java library for generating Time Sortable Identifiers (TSID).
Stars: ✭ 16 (-60%)
Mutual labels:  id, shortid
id-mask
IDMask is a Java library for masking internal ids (e.g. from your DB) when they need to be published to hide their actual value and to prevent forging. It has support optional randomisation has a wide support for various Java types including long, UUID and BigInteger. This library bases its security on strong cryptographic primitives.
Stars: ✭ 39 (-2.5%)
Mutual labels:  hashids, id
Laravel Optimus
Transform your internal id's to obfuscated integers based on Knuth's integer hash. Laravel wrapper for the Optimus Library by Jens Segers with multiple connections support.
Stars: ✭ 119 (+197.5%)
Mutual labels:  hashids
Laravel Hashslug
Package providing a trait to use Hashids on a model
Stars: ✭ 136 (+240%)
Mutual labels:  hashids
laravel-hashids
Laravel package for Hashids
Stars: ✭ 52 (+30%)
Mutual labels:  hashids
verify-apple-id-token
Verify the Apple id token on the server side.
Stars: ✭ 49 (+22.5%)
Mutual labels:  id
Optimus
🤖 Id obfuscation based on Knuth's multiplicative hashing method for PHP.
Stars: ✭ 1,084 (+2610%)
Mutual labels:  hashids
id3c
Data logistics system enabling real-time pathogen surveillance. Built for the Seattle Flu Study.
Stars: ✭ 21 (-47.5%)
Mutual labels:  plpgsql
Hashid Rails
Use Hashids (http://hashids.org/ruby/) in your Rails app ActiveRecord models.
Stars: ✭ 225 (+462.5%)
Mutual labels:  hashids
Eloquent Hashids
On-the-fly hashids for Laravel Eloquent models. (🍰 Easy & ⚡ Fast)
Stars: ✭ 196 (+390%)
Mutual labels:  hashids
Laravel Fakeid
Automatic model ID obfuscation in routes for Laravel
Stars: ✭ 161 (+302.5%)
Mutual labels:  hashids
shortid
Short id generator
Stars: ✭ 37 (-7.5%)
Mutual labels:  id
Laravel Hashids
A Hashids bridge for Laravel
Stars: ✭ 1,714 (+4185%)
Mutual labels:  hashids
serverless-go
Serverless Golang Function to Discover Movies 🎥
Stars: ✭ 37 (-7.5%)
Mutual labels:  rds
Acts as hashids
Use Youtube-Like ID in ActiveRecord seamlessly.
Stars: ✭ 76 (+90%)
Mutual labels:  hashids
serverless-examples-cached-rds-ws
A serverless framework example project that uses API Gateway, ElastiCache, and RDS PostgreSQL.
Stars: ✭ 45 (+12.5%)
Mutual labels:  rds
Django Rest Framework Serializer Extensions
Extensions to help DRY up Django Rest Framework serializers
Stars: ✭ 180 (+350%)
Mutual labels:  hashids
Hashids.github.io
Hashids website
Stars: ✭ 163 (+307.5%)
Mutual labels:  hashids
RDS-sanitized-snapshots
Take periodic snapshots of RDS databases, sanitize them, and share with other accounts. Useful for QA/dev databases.
Stars: ✭ 41 (+2.5%)
Mutual labels:  rds

PL/pgSQL implementation of Hashids

Hashids is a small open-source library that generates short, unique, non-sequential ids from numbers. It converts numbers like 347 into strings like “yr8”. You can also decode those ids back. This is useful in bundling several parameters into one or simply using them as short UIDs.

You can use hashids to hide primary keys in your database.

More information about hashids and it's implementations can be found here: hashids.org

Suitable for hosted environments like AWS RDS.

But if you are looking for an PG extention, then please check out pg_hashids repository.

Usage

Encoding

Returns a hash using the default alphabet and specified min_length and salt parameters.

select hashids.encode( number := 999, min_length := 6, salt := 'salt'); -- dkrMl8

number parameter can also be an array of numbers:

select hashids.encode( number := array[111,222], min_length := 6, salt := 'salt'); -- VyAHPK

It's also could be helpful to use it with sequences:

select hashids.encode( number := nextval('schema.sequence_name'), min_length := 6, salt := 'salt');

You can also decode previously generated hashes. Just use the same parameters salt, min_length and alphabet, otherwise you'll get wrong results.

select hashids.decode( id := 'dkrMl8', min_length := 6, salt := 'salt'); -- {999}
select hashids.decode( id := 'VyAHPK', min_length := 6, salt := 'salt'); -- {111,222}

Using custom alphabet, only capitalized letters and numbers:

select hashids.encode( number := 999, salt := 'salt', alphabet := 'ABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890'); -- D3Q5

Encode hex instead of numbers

Useful if you want to encode Mongo's ObjectIds. Note that there is no limit on how large of a hex number you can pass (it does not have to be Mongo's ObjectId).

select hashids.encode_hex( hex := '507f1f77bcf86cd799439011', salt := 'salt'); -- zro2yr9M4ZCzZ9zd9xYv

These ids can be also easily decoded back to their original values:

select hashids.decode_hex( id := 'zro2yr9M4ZCzZ9zd9xYv', salt := 'salt'); -- 507f1f77bcf86cd799439011
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].