Skip to main content

Module password

Module password 

Source
Expand description

Secure passwords and tokens (Rails has_secure_password / has_secure_token).

Passwords are hashed with bcrypt; a model exposes its stored digest via HasSecurePassword to gain authenticate.

Traits§

HasSecurePassword
Gives a model that stores a bcrypt digest an authenticate method.

Functions§

generate_token
Generate an unguessable token (256 bits, hex) for has_secure_token and one-off tokens (password reset, etc.).
hash_password
Hash a password with bcrypt at the default cost.
hash_password_with_cost
Hash a password with an explicit bcrypt cost (higher = slower/safer).
verify_password
Verify a plaintext password against a bcrypt digest (false on any error).