NAME

Dancer2::Plugin::Passphrase - Passphrases and Passwords as objects for Dancer2

SYNOPSIS

This plugin manages the hashing of passwords for Dancer2 apps, allowing developers to follow cryptography best practices without having to become a cryptography expert.

It uses the bcrypt algorithm as the default, while also supporting any hashing function provided by Digest

MORE INFORMATION

Purpose

The aim of this module is to help you store new passwords in a secure manner, whilst still being able to verify and upgrade older passwords.

Cryptography is a vast and complex field. Many people try to roll their own methods for securing user data, but succeed only in coming up with a system that has little real security.

This plugin provides a simple way of managing that complexity, allowing developers to follow crypto best practice without having to become an expert.

Rationale

The module defaults to hashing passwords using the bcrypt algorithm, returning them in RFC 2307 format.

RFC 2307 describes an encoding system for passphrase hashes, as used in the "userPassword" attribute in LDAP databases. It encodes hashes as ASCII text, and supports several passphrase schemes by starting the encoding with an alphanumeric scheme identifier enclosed in braces.

RFC 2307 only specifies the MD5, and SHA schemes - however in real-world usage, schemes that are salted are widely supported, and are thus provided by this module.

Bcrypt is an adaptive hashing algorithm that is designed to resist brute force attacks by including a cost (aka work factor). This cost increases the computational effort it takes to compute the hash.

SHA and MD5 are designed to be fast, and modern machines compute a billion hashes a second. With computers getting faster every day, brute forcing SHA hashes is a very real problem that cannot be easily solved.

Increasing the cost of generating a bcrypt hash is a trivial way to make brute forcing ineffective. With a low cost setting, bcrypt is just as secure as a more traditional SHA+salt scheme, and just as fast. Increasing the cost as computers become more powerful keeps you one step ahead

For a more detailed description of why bcrypt is preferred, see this article: http://codahale.com/how-to-safely-store-a-password/

Common Mistakes

Common mistakes people make when creating their own solution. If any of these seem familiar, you should probably be using this module