Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'digest'
- database = ['123456', 'monkey', '1ljflkdjsiolk', 'abcdefghijk']
- def sha256(digest)
- Digest::SHA256.hexdigest(digest)
- end
- puts "unencrypted passwords"
- puts database
- encrypted_passwords = database.map{|pw| sha256(pw << "salt")}
- puts "encrypted_passwords"
- puts encrypted_passwords
- passwords = [
- '123456',
- '123456789',
- 'qwerty',
- '12345678',
- '111111',
- '1234567890',
- '1234567',
- 'password',
- '123123',
- '987654321',
- 'qwertyuiop',
- 'mynoob',
- '123321',
- '666666',
- '18atcskd2w',
- '7777777',
- '1q2w3e4r',
- '654321',
- '555555',
- '3rjs1la7qe',
- 'google',
- '1q2w3e4r5t',
- '123qwe',
- 'zxcvbnm',
- '1q2w3e',
- ]
- rainbow_table = {}
- passwords.map{|pw| rainbow_table[sha256(pw)] = pw}
- puts "rainbow_table"
- puts rainbow_table
- puts "The encrypted password is: "
- puts rainbow_table[encrypted_passwords[0]]
Add Comment
Please, Sign In to add comment