All Projects → snaiper80 → hashids-erlang

snaiper80 / hashids-erlang

Licence: MIT license
The Erlang port of Hashid to generate YouTube-like hashids from one or many numbers.

Programming Languages

erlang
1774 projects
Makefile
30231 projects

Labels

Projects that are alternatives of or similar to hashids-erlang

laravel-hashid
HashId Implementation on Laravel Eloquent ORM
Stars: ✭ 23 (+21.05%)
Mutual labels:  hashid
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 (+105.26%)
Mutual labels:  hashid
objection-hashid
Objection plugin to automatically obfuscate model ids using hashids!
Stars: ✭ 13 (-31.58%)
Mutual labels:  hashid

hashids

Hashids

Build status

The Erlang port of Hashids from JavaScript.

Installation

Add Hashids as a dependency to rebar.config

{deps,
    [
        {hashids, ".*",  {git, "git://github.com/snaiper80/hashids-erlang.git",  {tag, "1.0.5"}}}
    ]
}.

Usage

Hashids encodes a integer or a list of integers.

1> hashids:new().   % create a new hashids context with default options
{hashids_context,"this is my salt",8,
                 "5N6y2rljDQak4xgzn8ZR1oKYLmJpEbVq3OBv9WwXPMe7",
                 "UHuhtcITCsFifS","AdG0"}

2> hashids:new([]). % same as new/0
{hashids_context,"this is my salt",8,
                 "5N6y2rljDQak4xgzn8ZR1oKYLmJpEbVq3OBv9WwXPMe7",
                 "UHuhtcITCsFifS","AdG0"}

3> Ctx = hashids:new([{salt, "this is my salt"}, {min_hash_length, 8}]).
{hashids_context,"this is my salt",8,
                 "5N6y2rljDQak4xgzn8ZR1oKYLmJpEbVq3OBv9WwXPMe7",
                 "UHuhtcITCsFifS","AdG0"}

4> Encoded = hashids:encode(Ctx, 12345).
"B0NkK9A5"

5> Encoded2 = hashids:encode(Ctx, [12345, 6789]).
"Y9awcOLv"

decode/2 returns a list of numbers

6> hashids:decode(Ctx, Encoded).
[12345]

7> hashids:decode(Ctx, Encoded2).
[12345,6789]

You can use customized characters (least 16 characters long)

Ctx = hashids:new([{salt, "this is my salt"},
                   {min_hash_length, 8}, {default_alphabet, "ABCDEFGhijklmn34567890-:"}]).

License

This software is licensed under the MIT license.

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].