https://github.com/snaiper80/hashids-erlang
  
  
    The Erlang port of Hashid to generate YouTube-like hashids from one or many numbers.  
    https://github.com/snaiper80/hashids-erlang
  
erlang hashid
        Last synced: 7 months ago 
        JSON representation
    
The Erlang port of Hashid to generate YouTube-like hashids from one or many numbers.
- Host: GitHub
- URL: https://github.com/snaiper80/hashids-erlang
- Owner: snaiper80
- License: mit
- Created: 2015-03-26T07:35:45.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2017-01-02T02:23:56.000Z (almost 9 years ago)
- Last Synced: 2025-03-19T09:40:41.708Z (8 months ago)
- Topics: erlang, hashid
- Language: Erlang
- Homepage: http://hashids.org/erlang
- Size: 1.04 MB
- Stars: 19
- Watchers: 1
- Forks: 10
- Open Issues: 0
- 
            Metadata Files:
            - Readme: README.md
- License: LICENSE
 
Awesome Lists containing this project
README
          # 
Hashids
=======
[](https://travis-ci.org/snaiper80/hashids-erlang)
The [Erlang][1] port of [Hashids][2] from JavaScript.
  [1]: http://www.erlang.org/
  [2]: http://www.hashids.org/
## Installation
Add Hashids as a dependency to rebar.config
```erlang
{deps,
    [
        {hashids, ".*",  {git, "git://github.com/snaiper80/hashids-erlang.git",  {tag, "1.0.5"}}}
    ]
}.
```
## Usage
Hashids encodes a integer or a list of integers.
```erlang
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
```erlang
6> hashids:decode(Ctx, Encoded).
[12345]
7> hashids:decode(Ctx, Encoded2).
[12345,6789]
```
You can use customized characters (least 16 characters long)
```erlang
Ctx = hashids:new([{salt, "this is my salt"},
                   {min_hash_length, 8}, {default_alphabet, "ABCDEFGhijklmn34567890-:"}]).
```
## License
This software is licensed under [the MIT license](LICENSE).