Skip to content

A simple implementation of PHPass’ Portable Hash.

License

Notifications You must be signed in to change notification settings

ostinelli/phpass

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status Hex pm

PHPass

PHPass is an Erlang port of the Portable PHP password hashing framework. Only the md5 hashing method is currently supported.

Setup

For Elixir

Add it to your deps:

defp deps do
  [{:phpass, "0.1.0"}]
end

Ensure that phpass is started with your application, for example by adding it to the list of your application's extra_applications:

def application do
  [
    extra_applications: [:logger, :phpass]
  ]
end

For Erlang

If you're using rebar3, add phpass as a dependency in your project's rebar.config file:

{deps, [
  {phpass, {git, "git://github.com/ostinelli/phpass.git", {tag, "0.1.0"}}}
]}.

Or, if you're using Hex.pm as package manager (with the rebar3_hex plugin):

{deps, [
  {phpass, "0.1.0"}
]}.

Ensure that phpass is started with your application, for example by adding it in your .app file to the list of applications:

{application, my_app, [
    %% ...
    {applications, [
        kernel,
        stdlib,
        sasl,
        phpass,
        %% ...
    ]},
    %% ...
]}.

API

Example code here below is in Erlang. Thanks to Elixir interoperability with Erlang, the equivalent code in Elixir is straightforward.

To hash a password:

phpass:hash(Password) ->
    phpass:hash(Password, 13).
phpass:hash(Password, Rounds) -> Hash.

Types:
    Password = binary()
    Rounds = non_neg_integer()
    Hash = binary()

To check a password:

phpass:check(Password, Hash) -> boolean().

Types:
    Password = binary()
    Hash = binary()

Implementation details

This is a port of the ruby implementation phpass-ruby. See original PHPass at Openwall.

Contributing

So you want to contribute? That's great! Please follow the guidelines below. It will make it easier to get merged in.

Before implementing a new feature, please submit a ticket to discuss what you intend to do. Your feature might already be in the works, or an alternative implementation might have already been discussed.

Do not commit to master in your fork. Provide a clean branch without merge commits. Every pull request should have its own topic branch. In this way, every additional adjustments to the original pull request might be done easily, and squashed with git rebase -i. The updated branch will be visible in the same pull request, so there will be no need to open new pull requests when there are changes to be applied.

Ensure that proper testing is included. To run tests you simply have to be in the project's root directory and run:

$ make test

About

A simple implementation of PHPass’ Portable Hash.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published