Skip to content

Instantly share code, notes, and snippets.

@natmchugh
Last active August 29, 2015 14:19
Show Gist options
  • Save natmchugh/fbd418c2657c3257dfee to your computer and use it in GitHub Desktop.
Save natmchugh/fbd418c2657c3257dfee to your computer and use it in GitHub Desktop.
require 'bcrypt'
my_password = "\0hello is it me you're looking for";
verify = BCrypt::Password.create(my_password)
puts my_password.inspect
# This password verifies according to bcrypt
puts verify == my_password ? ' password verified ' : 'password incorrect';
# but also ...
puts verify == '' ? ' But also verifies to a blank string' : 'Hey thats just a blank string';
# or indeed any password that starts with a null byte
puts verify == "\0I can see it you eyes" ? ' Yep password is good' : 'Hey thats different';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment