Guest User

Untitled

a guest
Jun 18th, 2018
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. require 'sha1'
  2. require 'md5'
  3.  
  4. class Authorization
  5. class << self
  6. def check( enc_password, raw_password )
  7. algo, salt, hsh = enc_password.split( "$" )
  8.  
  9. case algo
  10. when "md5" then MD5.md5( salt + raw_password ).to_s == hsh
  11. when "sha1" then SHA1.sha1( salt + raw_password ).to_s == hsh
  12. else
  13. false
  14. end
  15. end
  16. end
  17. end
Add Comment
Please, Sign In to add comment