Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Conversation

@mattwildig
Copy link
Contributor

This is a fix for #106. It looks fairly simple so I thought I’d do a quick PR.

When splitting the hash into the components to populate the attributes in Password the salt and hash were being converted into plain strings with to_str, but the version wasn’t. This was causing problems when trying to use == on that attribute (a change to Psych to how strings are serialized to Yaml does this).

This fix just adds a call to to_str to the version, to match the salt and hash (the cost is converted with to_i) and adds a matching spec.


As an aside: This fixes the immediate issue. Dumping a Password to Yaml now looks something like this:

--- !ruby/string:BCrypt::Password
str: "$2a$10$xbRosG0W6.XkTBSWYDTaVeFTNtWa3uHwudnwLme.KAKkVYMSalqLW"
version: 2a
cost: 10
salt: "$2a$10$xbRosG0W6.XkTBSWYDTaVe"
checksum: FTNtWa3uHwudnwLme.KAKkVYMSalqLW

which is what it looked like in Ruby 2.1 (or more accurately with the version of Psych in Ruby 2.1). The version, cost, salt and checksum are all duplicated. Is it worth adding init_with and encode_with methods to avoid this repetition?

@tmm1
Copy link
Collaborator

tmm1 commented Jan 28, 2015

This looks reasonable. WDYT @tjschuck ?

@tjschuck
Copy link
Collaborator

Yep, this looks good to me.

Sorry for the delay, @mattwildig, and thanks! ❤️ ❤️ 😻 ❤️

tjschuck added a commit that referenced this pull request Jan 29, 2015
@tjschuck tjschuck merged commit 3aa15b6 into bcrypt-ruby:master Jan 29, 2015
@tjschuck
Copy link
Collaborator

(Building and publishing a new version of the gem shortly -- stay tuned for that.)

@tjschuck
Copy link
Collaborator

@mattwildig @tmm1 Version 3.1.10 has been pushed to RubyGems.

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

Successfully merging this pull request may close these issues.

3 participants

Morty Proxy This is a proxified and sanitized view of the page, visit original site.