Created
August 6, 2018 23:14
-
-
Save kuczmama/2bf3b206f9571ef6970d57665a1d8069 to your computer and use it in GitHub Desktop.
What is sha 256
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' | |
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]] | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment