PhcStringFormat

Gem Version Build Status Known Vulnerabilities Codacy Badge Codacy Badge

PHC string format implemented by Ruby

Installation

Add this line to your application's Gemfile:

gem 'phc_string_format'

And then execute:

$ bundle

Or install it yourself as:

$ gem install phc_string_format

Usage

require 'phc_string_format'

encrypted_password = '$argon2i$v=19$m=4096,t=3,p=1$IfH5R3O3r3501DfGnGr2rw$DfQ8Hv9R2eF2uBs1dR99IGjVjDl/rpkJIkaNyZ1g3pk'

# parse
phc_string_args = PhcStringFormat::Formatter.parse(encrypted_password)
# => {:id=>"argon2i", :version=>19, :params=>{"m"=>4096, "t"=>3, "p"=>1}, :salt=>"!\xF1\xF9Gs\xB7\xAF~t\xD47\xC6\x9Cj\xF6\xAF", :hash=>"\r\xF4<\x1E\xFFQ\xD9\xE1v\xB8\e5u\x1F} h\xD5\x8C9\x7F\xAE\x99\t\"F\x8D\xC9\x9D`\xDE\x99"}

# format
password_hash = PhcStringFormat::Formatter.format(phc_string_args)

password_hash == encrypted_password

Development

After checking out the repo, run bin/setup to install dependencies. You can also run bin/console for an interactive prompt that will allow you to experiment.

To install this gem onto your local machine, run bundle exec rake install. To release a new version, update the version number in version.rb, and then run bundle exec rake release, which will create a git tag for the version, push git commits and tags, and push the .gem file to rubygems.org.

Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/naokikimura/phc_string_format.

License

The gem is available as open source under the terms of the MIT License.