Skip to content

Commit

Permalink
Merge pull request #33 from kianmeng/misc-doc-changes
Browse files Browse the repository at this point in the history
Misc doc changes
  • Loading branch information
riverrun authored Jan 25, 2021
2 parents aa35ad4 + 14ede6e commit 8ee684d
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 58 deletions.
20 changes: 19 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,26 @@
# The directory Mix will write compiled artifacts to.
/_build/

# If you run "mix test --cover", coverage assets end up here.
/cover/

# The directory Mix downloads your dependencies sources to.
/deps/

# Where third-party dependencies like ExDoc output generated docs.
/doc/
/priv/

# Ignore .fetch files in case you like to edit your project deps locally.
/.fetch

# If the VM crashes, it generates a dump, let's ignore it too.
erl_crash.dump

# Also ignore archive artifacts (built via "mix archive.build").
*.ez

# Ignore package tarball (built via "mix hex.build").
bcrypt_elixir-*.tar

# Temporary files for e.g. tests
/tmp
16 changes: 8 additions & 8 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,31 +1,31 @@
# Changelog

## v2.3.0
## v2.3.0 (2021-01-07)

* Enhancements
* updated Makefile to be more robust, especially for Nerves users
* Updated Makefile to be more robust, especially for Nerves users

## v2.2.0
## v2.2.0 (2020-03-01)

* Changes
* using Comeonin v5.3, which changes `add_hash` so that it does NOT set the password to nil
* Using Comeonin v5.3, which changes `add_hash` so that it does NOT set the password to nil

## v2.1.0
## v2.1.0 (2020-01-20)

* Enhancements
* Updated documentation - in line with updates to Comeonin v5.2

## v2.0.0
## v2.0.0 (2019-02-12)

* Enhancements
* Updated to use the Comeonin and Comeonin.PasswordHash behaviours (Comeonin v5.0)

## v1.0.0
## v1.0.0 (2019-01-17)

* Enhancements
* Updated C NIF code to use dirty schedulers

## v0.12.0
## v0.12.0 (2017-08-06)

* Changes
* Created separate Bcrypt library
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ This password hashing algorithm was designed by David Mazieres
All other code in this application, unless otherwise stated, is subject
to the following license:

Copyright (c) 2014-2018 David Whitlock <[email protected]>
Copyright (c) 2014-2021 David Whitlock <[email protected]>

Some rights reserved.
Redistribution and use in source and binary forms of the software as well
Expand Down
74 changes: 39 additions & 35 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
# Bcrypt

[![Hex.pm Version](http://img.shields.io/hexpm/v/bcrypt_elixir.svg)](https://hex.pm/packages/bcrypt_elixir)
[![Build Status](https://travis-ci.com/riverrun/bcrypt_elixir.svg?branch=master)](https://travis-ci.com/riverrun/bcrypt_elixir)
[![Module Version](http://img.shields.io/hexpm/v/bcrypt_elixir.svg)](https://hex.pm/packages/bcrypt_elixir)
[![Hex Docs](https://img.shields.io/badge/hex-docs-lightgreen.svg)](https://hexdocs.pm/bcrypt_elixir/)
[![Total Download](https://img.shields.io/hexpm/dt/bcrypt_elixir.svg)](https://hex.pm/packages/bcrypt_elixir)
[![License](https://img.shields.io/hexpm/l/bcrypt_elixir.svg)](https://github.com/riverrun/bcrypt_elixir/blob/master/LICENSE)
[![Last Updated](https://img.shields.io/github/last-commit/riverrun/bcrypt_elixir.svg)](https://github.com/riverrun/bcrypt_elixir/commits/master)

Bcrypt password hashing library for Elixir.

Expand All @@ -23,72 +27,72 @@ and Comeonin.PasswordHash behaviours.
It now has the following two additional convenience functions:

* `add_hash/2`
* same as Comeonin.Bcrypt.add_hash in Comeonin version 4
* same as `Comeonin.Bcrypt.add_hash/2` in Comeonin version 4
* hashes a password and returns a map with the password hash
* `check_pass/3`
* same as Comeonin.Bcrypt.check_pass in Comeonin version 4
* same as `Comeonin.Bcrypt.check_pass/3` in Comeonin version 4
* takes a user struct and password as input and verifies the password

## Installation

1. Add bcrypt_elixir to the `deps` section of your mix.exs file:
1. Add `:bcrypt_elixir` to the `deps` section of your `mix.exs` file:

If you are using Erlang >20:
If you are using Erlang >20:

```elixir
def deps do
[
{:bcrypt_elixir, "~> 2.0"}
]
end
```
```elixir
def deps do
[
{:bcrypt_elixir, "~> 2.0"}
]
end
```

If you are using Erlang 19 or below:
If you are using Erlang 19 or below:

```elixir
def deps do
[
{:bcrypt_elixir, "~> 0.12"}
]
end
```
```elixir
def deps do
[
{:bcrypt_elixir, "~> 0.12"}
]
end
```

2. Make sure you have a C compiler installed.
2. Make sure you have a C compiler installed.
See the [Comeonin wiki](https://github.com/riverrun/comeonin/wiki/Requirements) for details.

3. Optional: during tests (and tests only), you may want to reduce the number of rounds
3. Optional: during tests (and tests only), you may want to reduce the number of rounds
so it does not slow down your test suite. If you have a config/test.exs, you should
add:

```elixir
config :bcrypt_elixir, :log_rounds, 4
```
```elixir
config :bcrypt_elixir, :log_rounds, 4
```

## Comeonin wiki

See the [Comeonin wiki](https://github.com/riverrun/comeonin/wiki) for more
information on the following topics:

* [algorithms](https://github.com/riverrun/comeonin/wiki/Choosing-the-password-hashing-algorithm)
* [requirements](https://github.com/riverrun/comeonin/wiki/Requirements)
* [deployment](https://github.com/riverrun/comeonin/wiki/Deployment)
* including information about using Docker
* [references](https://github.com/riverrun/comeonin/wiki/References)
* [Algorithms](https://github.com/riverrun/comeonin/wiki/Choosing-the-password-hashing-algorithm)
* [Requirements](https://github.com/riverrun/comeonin/wiki/Requirements)
* [Deployment](https://github.com/riverrun/comeonin/wiki/Deployment)
* Including information about using Docker
* [References](https://github.com/riverrun/comeonin/wiki/References)

## Contributing

There are many ways you can contribute to the development of this library, including:

* reporting issues
* improving documentation
* sharing your experiences with others
* [making a financial contribution](#donations)
* Reporting issues
* Improving documentation
* Sharing your experiences with others
* [Making a financial contribution](#donations)

## Donations

First of all, I would like to emphasize that this software is offered
free of charge. However, if you find it useful, and you would like to
buy me a cup of coffee, you can do so at [paypal](https://www.paypal.me/alovedalongthe).
buy me a cup of coffee, you can do so at [PayPal](https://www.paypal.me/alovedalongthe).

### Documentation

Expand Down
15 changes: 7 additions & 8 deletions lib/bcrypt.ex
Original file line number Diff line number Diff line change
Expand Up @@ -5,22 +5,21 @@ defmodule Bcrypt do
Most applications will just need to use the `add_hash/2` and `check_pass/3`
convenience functions in this module.
For a lower-level API, see Bcrypt.Base.
For a lower-level API, see `Bcrypt.Base`.
## Configuration
The following parameter can be set in the config file:
* `log_rounds` - the computational cost as number of log rounds
* the default is 12 (2^12 rounds)
* `:log_rounds` - the computational cost as number of log rounds
* the default is `12` (2^12 rounds)
If you are hashing passwords in your tests, it can be useful to add
the following to the `config/test.exs` file:
# Note: Do not use this value in production
config :bcrypt_elixir, log_rounds: 4
NB. do not use this value in production.
## Bcrypt
Bcrypt is a key derivation function for passwords designed by Niels Provos
Expand Down Expand Up @@ -54,11 +53,11 @@ defmodule Bcrypt do
@doc """
Generate a salt for use with the `Bcrypt.Base.hash_password` function.
The log_rounds parameter determines the computational complexity
The `:log_rounds` parameter determines the computational complexity
of the generation of the password hash. Its default is 12, the minimum is 4,
and the maximum is 31.
The `legacy` option is for generating salts with the old `$2a$` prefix.
The `:legacy` option is for generating salts with the old `$2a$` prefix.
Only use this option if you need to generate hashes that are then checked
by older libraries.
"""
Expand All @@ -71,7 +70,7 @@ defmodule Bcrypt do
## Option
* `log_rounds` - the computational cost as number of log rounds
* `:log_rounds` - the computational cost as number of log rounds
* the default is 12 (2^12 rounds)
* this can be used to override the value set in the config
Expand Down
6 changes: 3 additions & 3 deletions lib/bcrypt/stats.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ defmodule Bcrypt.Stats do
@moduledoc """
Module to provide statistics for the Bcrypt password hashing function.
The `report` function in this module can be used to help you configure
The `report/1` function in this module can be used to help you configure
Bcrypt.
## Configuration
There is one configuration option for Bcrypt - log_rounds.
There is one configuration option for Bcrypt - `:log_rounds`.
Increasing this value will increase the complexity, and time
taken, of the Bcrypt function.
Expand All @@ -26,7 +26,7 @@ defmodule Bcrypt.Stats do
@doc """
Hash a password with Bcrypt and print out a report.
This function hashes a password, and salt, with Bcrypt.Base.hash_password/2
This function hashes a password, and salt, with `Bcrypt.Base.hash_password/2`
and prints out statistics which can help you choose how many to configure
Bcrypt.
Expand Down
18 changes: 16 additions & 2 deletions mix.exs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
defmodule BcryptElixir.Mixfile do
use Mix.Project

@source_url "https://github.com/riverrun/bcrypt_elixir"
@version "2.3.0"

@description """
Expand All @@ -18,8 +19,9 @@ defmodule BcryptElixir.Mixfile do
make_clean: ["clean"],
description: @description,
package: package(),
source_url: "https://github.com/riverrun/bcrypt_elixir",
source_url: @source_url,
deps: deps(),
docs: docs(),
dialyzer: [
plt_file: {:no_warn, "priv/plts/dialyzer.plt"}
]
Expand All @@ -41,12 +43,24 @@ defmodule BcryptElixir.Mixfile do
]
end

defp docs do
[
main: "readme",
source_ref: "v#{@version}",
source_url: @source_url,
extras: ["CHANGELOG.md", "README.md"]
]
end

defp package do
[
files: ["lib", "c_src", "mix.exs", "Makefile*", "README.md", "LICENSE"],
maintainers: ["David Whitlock"],
licenses: ["BSD"],
links: %{"GitHub" => "https://github.com/riverrun/bcrypt_elixir"}
links: %{
"Changelog" => "#{@source_url}/blob/master/CHANGELOG.md",
"GitHub" => @source_url
}
]
end
end

0 comments on commit 8ee684d

Please sign in to comment.