Skip to content

Instantly share code, notes, and snippets.

@neontuna
Last active February 6, 2025 19:29
Show Gist options
  • Save neontuna/dffd0452d09a0861106c0a46669a3ff0 to your computer and use it in GitHub Desktop.
Save neontuna/dffd0452d09a0861106c0a46669a3ff0 to your computer and use it in GitHub Desktop.
normalPassword = BCrypt::Password.create('love')
otherPassword = 'hate'
> normalPassword == otherPassword
=> false
userId = SecureRandom.alphanumeric(18)
username = SecureRandom.alphanumeric(55)
password = 'super-duper-secure-password'
combined = "#{userId}:#{username}:#{password}"
hash = BCrypt::Password.create(combined)
bad_password = 'not-the-same'
bad_string = "#{userId}:#{username}:#{bad_password}"
> hash == bad_string
=> true
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment