-
Notifications
You must be signed in to change notification settings - Fork 252
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
Make the generate()
method more idiomatic...
#326
Make the generate()
method more idiomatic...
#326
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for this! A small adjustment and I think this is ready.
when :ssha | ||
salt = SecureRandom.random_bytes(16) | ||
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! | ||
'{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think https://ruby-doc.org/stdlib/libdoc/base64/rdoc/Base64.html#method-i-strict_encode64 would make this even more simple and not require calling #chomp
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the feedback!
The changes in this PR (as well as the similar ones in #327 and #328) focussed on suppressing the Ruby warnings, whilst shying away from making any functional changes.
I'll gladly do the functional refactoring you suggested as well, but how do you feel about merging this PR as is, and I'll follow up immediately afterwards with the further more functional refactoring?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that works for me.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in #362!
when :ssha | ||
salt = SecureRandom.random_bytes(16) | ||
attribute_value = '{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! | ||
'{SSHA}' + Base64.encode64(Digest::SHA1.digest(str + salt) + salt).chomp! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
OK, that works for me.
... and fix the following Ruby warning in the process:
Doesn't change anything functionally, and the tests still pass! 😃