Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/selectel/etsdangerous
An Erlang port of itsdangerous
https://github.com/selectel/etsdangerous
community erlang
Last synced: 2 days ago
JSON representation
An Erlang port of itsdangerous
- Host: GitHub
- URL: https://github.com/selectel/etsdangerous
- Owner: selectel
- License: mit
- Created: 2013-12-20T15:05:38.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2016-03-31T14:01:13.000Z (over 8 years ago)
- Last Synced: 2024-03-25T22:22:45.897Z (9 months ago)
- Topics: community, erlang
- Language: Erlang
- Homepage:
- Size: 6.84 KB
- Stars: 5
- Watchers: 20
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# etsdangerous [![Build Status][travis-img]][travis]
[travis]: http://travis-ci.org/selectel/etsdangerous
[travis-img]: https://travis-ci.org/selectel/etsdangerous.svg__Authors:__ [Dmitry Groshev](https://github.com/si14/), [Sergei Lebedev](https://github.com/superbobry/).
An Erlang port of [itsdangerous](https://github.com/mitsuhiko/itsdangerous).
Quick examples
--------------#### Signing:
```erlang
1> S = etsdangerous:signer(<<"secret-key>>>).
{signer,untimed,<<"secret-key">>,<<"etsdangerous.Signer">>,
<<".">>}
2> D = etsdangerous:sign(S, <<"data">>).
<<"data.tfT7zMsPOFv84VxV6CUew_09xvs">>
3> etsdangerous:unsign(S, D).
{ok,{<<"data">>,undefined}}
```#### Expiring signatures:
```erlang
1> S = etsdangerous:ts_signer(<<"secret-key">>, 10).
{signer,{timed,10},
<<"secret-key">>,<<"etsdangerous.Signer">>,<<".">>}
2> D = etsdangerous:sign(S, <<"data">>).
<<"data.BCyr0A.qmWS3-TkJ9eiElgZELGmubxsuRA">>
3> etsdangerous:unsign(S, D).
{ok,{<<"data">>,{{2013,3,21},{14,33,52}}}}
...
4> etsdangerous:unsign(S, D).
{error,signature_expired}
```#### Salt:
```erlang
1> S1 = etsdangerous:signer(<<"secret-key">>, <<"salt-1">>).
{signer,untimed,<<"secret-key">>,<<"salt-1">>,<<".">>}
2> S2 = etsdangerous:signer(<<"secret-key">>, <<"salt-2">>).
{signer,untimed,<<"secret-key">>,<<"salt-2">>,<<".">>}
3> D = etsdangerous:sign(S1, <<"data">>).
<<"data.siZlJhySx8NoTIwrmOmupfvGnO8">>
4> etsdangerous:unsign(S2, D).
{error,bad_signature}
```