https://github.com/sdalu/easy-password
Password generator, checker, hasher
https://github.com/sdalu/easy-password
password password-generator password-strength ruby
Last synced: 2 months ago
JSON representation
Password generator, checker, hasher
- Host: GitHub
- URL: https://github.com/sdalu/easy-password
- Owner: sdalu
- License: mit
- Created: 2021-05-27T08:31:56.000Z (about 5 years ago)
- Default Branch: main
- Last Pushed: 2024-09-05T13:41:19.000Z (almost 2 years ago)
- Last Synced: 2025-12-01T04:51:00.811Z (7 months ago)
- Topics: password, password-generator, password-strength, ruby
- Language: Ruby
- Homepage:
- Size: 7.81 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
easy-password
=============
Password generator, checker, hasher
Examples
========
Adding a simple password generator and using it by default:
~~~ruby
# Generate 10 random alphanumeric characters
EasyPassword.generator :random10 do
SecureRandom.alphanumeric(10)
end
# Define the default generator
EasyPassword.default_generator = :random10
~~~
Adding a checker
~~~ruby
# Implementing classic at least 1 lowercase, 1 upercase, 1 digit
EasyPassword.checker :aA1 do |password, all|
list = { /\d/ => :digit_needed,
/[A-Z]/ => :upercase_needed,
/[a-z]/ => :lowercase_needed,
}.lazy.map {|regex, failure| failure if password !~ regex }
.reject(&:nil?)
all ? list.to_a : list.first
end
# Looking for known bad passwords in a database (using Sequel)
Password.checker :hack_dictionary do |password, all|
! DB[:bad_passwords].first(:password => password).nil?
end
~~~
Creating password
~~~ruby
password = EasyPassword.new
password = EasyPassword.new('foobar')
~~~
Checking for weakness
~~~ruby
password.weakness
~~~