Last active
August 29, 2015 14:13
-
-
Save booty/5f7d3e4264fcc535715f to your computer and use it in GitHub Desktop.
Ruby: Better Message Security Through Floating-Point Hash Keys
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
x = { 'foo' => 'Normal Message', (0.1 + 0.02) => 'Secret Message' } | |
# Outputs 'Normal Message' | |
puts x['foo'] | |
# Outputs NOTHING because 0.1 + 0.02 equals 0.12000000000000001, not 0.12! | |
# (The Russians wil never find the secret message!) | |
puts x[0.12] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment