# RandomPassword

Efficiently generate cryptographically strong random passwords using alpha, numeric and special symbols.

[![Build Status](](   [![Hex Version]( "Hex Version")](   [![License: MIT](]()

## <a name="Installation"></a>Installation

Add `random_password` to `mix.exs` dependencies:

  def deps,
    do: [ 
      {:random_password, "~> 1.0"}

Update dependencies

  mix deps.get


## <a name="Usage"></a>Usage

Create a module for generating random passwords:

  iex> defmodule(DefaultPassword, do: use(RandomPassword))
  iex> DefaultPassword.generate()

By default, `RandomPassword` modules generate passwords of length 17, comprised of 14 alpha, 2 decimal, and 1 symbol. To specify different character counts, supply any combination of `alpha`, `decimal` or `symbol` during module creation:

  iex> defmodule(StrongPassword, do: use(RandomPassword, alpha: 16, decimal: 4, symbol: 2))
  iex> StrongPassword.generate()

A specific set of symbols can be specified using the `symbols` option:

  iex> defmodule(CustomSymbolsPassword, do: use(RandomPassword, alpha: 12, symbol: 3, symbols: "@#$%&!"))
  iex> CustomSymbolsPassword.generate()

Each created module includes a `info/0` function to display module parameterization:

    alpha: 16,
    decimal: 4,
    entropy_bits: 114.11,
    length: 22,
    symbol: 2,
    symbols: "!#$%&()*+,-./:;<=>?@[]^_{|}~"

`info/0` output includes a calculation of bits of entropy for generated passwords. `RandomPassword.entropy_bits/3` can be used to calculate entropy bits. For example, using the parameters passed when creating `StrongPassword`, password entropy can determine **_before_** creating the module:

  iex> RandomPassword.entropy_bits(16, 4, 2) |> Float.round(2)