No commit activity in last 3 years
No release in over 3 years
A simple gem to check and see if a given password was compromised by a hack. Special thanks to Troy Hunt for facilitating haveibeenpwned.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
2025
 Dependencies

Development

>= 0.1.10
>= 0
>= 0

Runtime

>= 0.17.0
 Project Readme

haveibeenpwned-ruby-sdk

Ruby wrapper for V2 haveibeenpwned.com API.

Build Status codecov Gem

Installation

gem install have-i-been-pwned

Use

General Use

require 'have-i-been-pwned'
...
# returns true if the password is found, false otherwise
result = HaveIBeenPwned.pwned 'abc123'
require 'have-i-been-pwned'
...
# returns an array with symbolized hashs of breachers (ie. [ { :name => 'Adobe' } ]) for that account, nil if none are found
result = HaveIBeenPwned.pwned_account 'some-email@gmail.com'

Rails

# Gemfile
gem 'have-i-been-pwned'
# some controller
# check the password
if !HaveIBeenPwned.pwned params[:password]
   puts "Yay! You can use this password!"
else
   puts "No! Bad!!"
end

Timeout

With both the pwned and pwned_account methods you can also introduce a custom timeout. By default the timeout is 30 seconds. You can customize the timeout to meet your needs like so:

HaveIBeenPwned.pwned 'abc123', timeout: 10

Contributing

  • Open an issue about your change
  • Fork it, DL it
  • Run bundle
  • Run bundle exec rake
  • Make your additions, changes, fixes, etc. (Do not make changes to version, Rakefile or spec
  • Add tests for the above (no pr acceptance without them)
  • Run bundle exec rake
  • Make your PR. 😄