Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/marianoguerra/erlang-pbkdf2-no-history
basho/erlang-pbkdf2 repo withouth couchdb history to reduce repo size
https://github.com/marianoguerra/erlang-pbkdf2-no-history
Last synced: about 1 month ago
JSON representation
basho/erlang-pbkdf2 repo withouth couchdb history to reduce repo size
- Host: GitHub
- URL: https://github.com/marianoguerra/erlang-pbkdf2-no-history
- Owner: marianoguerra
- License: apache-2.0
- Created: 2015-08-19T11:14:54.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-19T11:15:50.000Z (about 9 years ago)
- Last Synced: 2023-04-21T08:16:31.200Z (over 1 year ago)
- Language: Erlang
- Size: 273 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGES
- License: LICENSE
Awesome Lists containing this project
README
erlang-pbkdf2
=============A [PBKDF2][] implementation for [Erlang][] extracted from [Apache CouchDB][].
[Full erlang-pbkdf2 repo (see note below)]: https://github.com/basho/erlang-pbkdf2
[PBKDF2]: http://en.wikipedia.org/wiki/PBKDF2
[Erlang]: http://www.erlang.org
[Apache CouchDB]: http://couchdb.apache.orgNOTE:
this repo is a clean import of the pbkdf2 module without the couchdb git
history to avoid downloading 14MBs of history for a library with ~200 lines
of code, if you want the full history use this repository:
https://github.com/basho/erlang-pbkdf2Building
--------`erlang-pbkdf2` uses [rebar][] to manage the build process. To build the project, run:
./rebar compile
You can then run the `xref` and `eunit` tests:
./rebar xref eunit
If you want to remove all generated files, run:
./rebar clean
[rebar]: https://github.com/rebar/rebar/wiki
Usage
-----```erlang
OriginalPassword = <<"password">>.% Settings
{Salt, Iterations, DerivedLength} = {<<"salt">>, 4096, 20}.% Hash the original password.
{ok, Key} = pbkdf2:pbkdf2(OriginalPassword, Salt, Iterations, DerivedLength).% At this point, Key = <<"4b007901b765489abead49d926f721d065a429c1">>.
% Get the password from the user.
EnteredPassword = getpass().% Ensure that the entered password is the same as the original.
{ok, Key} = pbkdf2:pbkdf2(EnteredPassword, Salt, Iterations, DerivedLength).
```If you're curious what `getpass/0` would look like, here's a sample implementation:
```erlang
% Get the password from the user.
getpass() ->
% Store current options for stdio.
InitialIOOpts = io:getopts(),
% Disable input character echo.
ok = io:setopts([{echo, false}]),
% Prompt the user for a password.
EnteredPassword = io:get_line("Password: "),
% Restore original options for stdio.
ok = io:setopts(InitialIOOpts),
% Print a newline, since we had local echo disabled above.
io:format("\n"),
% Remove trailing newline character, if present.
case lists:reverse(EnteredPassword) of
[$\n | Rest] ->
lists:reverse(Rest);
_ ->
EnteredPassword
end.
```Cryptographic Software Notice
-----------------------------This distribution includes cryptographic software. The country in which you
currently reside may have restrictions on the import, possession, use, and/or
re-export to another country, of encryption software. BEFORE using any
encryption software, please check your country's laws, regulations and policies
concerning the import, possession, or use, and re-export of encryption software,
to see if this is permitted. See for more
information.The U.S. Government Department of Commerce, Bureau of Industry and Security
(BIS), has classified this software as Export Commodity Control Number (ECCN)
5D002.C.1, which includes information security software using or performing
cryptographic functions with asymmetric algorithms. The form and manner of this
Apache Software Foundation distribution makes it eligible for export under the
License Exception ENC Technology Software Unrestricted (TSU) exception (see the
BIS Export Administration Regulations, Section 740.13) for both object code and
source code.The following provides more details on the included cryptographic software:
`erlang-pbkdf2` implements the PBKDF2 key derivation function.