Skip to content
PHC string format implemented by Ruby
Ruby Shell
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
bin
lib
spec
.gitignore
.reek.yml
.rspec
.rubocop.yml
.simplecov
.travis.yml
CODE_OF_CONDUCT.md
Gemfile
Gemfile.lock
LICENSE.txt
README.md
Rakefile
phc_string_format.gemspec

README.md

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.

You can’t perform that action at this time.