Created
November 14, 2012 16:12
-
-
Save piotrplaneta/4073031 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| require 'digest/sha1' | |
| bob_texts_c = [] | |
| mallory_texts_c = [] | |
| bob_texts = {} | |
| mallory_texts = {} | |
| bob_text = 'Wyplacic Bobowi 100 zlotych.' | |
| mallory_text = 'Wyplacic Mallory 100 zlotych.' | |
| letters = ('a'..'z').to_a | |
| puts letters.combination(2).to_a.length | |
| letters.combination(2).each_with_index do |word, index| | |
| bob_texts_c.push(Digest::SHA1.hexdigest(bob_text + word.join)[-4, 4]) | |
| bob_texts[Digest::SHA1.hexdigest(bob_text + word.join)[-4, 4]] = (bob_text + word.join) | |
| mallory_texts_c.push(Digest::SHA1.hexdigest(mallory_text + word.join)[-4, 4]) | |
| mallory_texts[Digest::SHA1.hexdigest(mallory_text + word.join)[-4, 4]] = (mallory_text + word.join) | |
| end | |
| (bob_texts_c & mallory_texts_c).each do |text| | |
| puts bob_texts[text] + " = " + mallory_texts[text] | |
| end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment