Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Argon2::Password.hash overrides Object#hash in an incompatible manner #9

Closed
dgutov opened this issue Feb 15, 2016 · 5 comments
Closed

Comments

@dgutov
Copy link

dgutov commented Feb 15, 2016

Which makes it impossible to use the class as a key in a hash, for instance:

$ irb
irb(main):001:0> require 'argon2'
=> true
irb(main):002:0> h = {}
=> {}
irb(main):003:0> h[Argon2::Password] = 42
ArgumentError: wrong number of arguments (0 for 1)
    from /home/gutov/.rbenv/versions/2.1.2/lib/ruby/gems/2.1.0/gems/argon2-0.1.4/lib/argon2.rb:25:in `hash'
    from (irb):3
    from /home/gutov/.rbenv/versions/2.1.2/bin/irb:11:in `<main>'
@technion
Copy link
Owner

I could change the hash function to "create" in line with other similar gems. However, this would be a breaking change. Therefore I would have to ask, is the above code something you would ever write in practice?

@dgutov
Copy link
Author

dgutov commented Feb 15, 2016

Yup. I use a hash to cache class names here: https://github.com/dgutov/robe/blob/master/lib/robe/sash.rb#L38

It's a dynamic code assistance tool.

@technion
Copy link
Owner

Sounds like I'm sold. Incoming fix.

@technion
Copy link
Owner

This requires an obvious version bump. I've done so in the source, I'll let it settle a few days before tagging a release.

@dgutov
Copy link
Author

dgutov commented Feb 16, 2016

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants