GithubHelp home page GithubHelp logo

basho / erlang-pbkdf2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from whitelynx/erlang-pbkdf2

18.0 82.0 44.0 15.35 MB

Mirror of Apache CouchDB

License: Apache License 2.0

Erlang 89.98% C 9.05% Makefile 0.97%

erlang-pbkdf2's Introduction

erlang-pbkdf2

Erlang CI Actions Status

A PBKDF2 implementation for Erlang extracted from Apache CouchDB.

Building

erlang-pbkdf2 uses [rebar3][] to manage the build process. To build the project, run:

./rebar3 compile

You can then run the xref and eunit tests:

./rebar3 xref eunit

If you want to remove all generated files, run:

./rebar3 clean

Usage

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:

% 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 http://www.wassenaar.org/ 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.

erlang-pbkdf2's People

Contributors

adamlofts avatar akaspin avatar asbaker avatar bjnortier avatar calebcase avatar cmlenz avatar daleharvey avatar davisp avatar dch avatar dustin avatar fdmanana avatar janl avatar jaredmorrow avatar jasondavies avatar jchris avatar joelwreed avatar keksov avatar klaustrainer avatar kocolosk avatar kxepal avatar maghoff avatar martinsumner avatar mrloop avatar rnewson avatar ronnypfannschmidt avatar russelldb avatar sbisbee avatar tilgovi avatar vagabond avatar whitelynx avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.