Guest User

Untitled

a guest
Aug 6th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.77 KB | None | 0 0
  1. require 'digest'
  2.  
  3. database = ['123456', 'monkey', '1ljflkdjsiolk', 'abcdefghijk']
  4.  
  5. def sha256(digest)
  6. Digest::SHA256.hexdigest(digest)
  7. end
  8.  
  9. puts "unencrypted passwords"
  10. puts database
  11.  
  12. encrypted_passwords = database.map{|pw| sha256(pw << "salt")}
  13.  
  14. puts "encrypted_passwords"
  15. puts encrypted_passwords
  16.  
  17. passwords = [
  18. '123456',
  19. '123456789',
  20. 'qwerty',
  21. '12345678',
  22. '111111',
  23. '1234567890',
  24. '1234567',
  25. 'password',
  26. '123123',
  27. '987654321',
  28. 'qwertyuiop',
  29. 'mynoob',
  30. '123321',
  31. '666666',
  32. '18atcskd2w',
  33. '7777777',
  34. '1q2w3e4r',
  35. '654321',
  36. '555555',
  37. '3rjs1la7qe',
  38. 'google',
  39. '1q2w3e4r5t',
  40. '123qwe',
  41. 'zxcvbnm',
  42. '1q2w3e',
  43. ]
  44.  
  45. rainbow_table = {}
  46. passwords.map{|pw| rainbow_table[sha256(pw)] = pw}
  47.  
  48. puts "rainbow_table"
  49. puts rainbow_table
  50.  
  51. puts "The encrypted password is: "
  52. puts rainbow_table[encrypted_passwords[0]]
Add Comment
Please, Sign In to add comment