Class: Phpass::Md5
- Inherits:
-
Object
- Object
- Phpass::Md5
- Defined in:
- lib/phpass/md5.rb
Instance Method Summary collapse
- #check(pw, hash) ⇒ Object
- #hash(pw) ⇒ Object
-
#initialize(stretch = 8) ⇒ Md5
constructor
A new instance of Md5.
Constructor Details
#initialize(stretch = 8) ⇒ Md5
Returns a new instance of Md5.
7 8 9 10 11 12 |
# File 'lib/phpass/md5.rb', line 7 def initialize(stretch=8) @itoa64 = './0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz' stretch = 8 unless (8..30).include?(stretch) @stretch = stretch @random_state = '%s%s' % [Time.now.to_f, $$] end |
Instance Method Details
#check(pw, hash) ⇒ Object
20 21 22 |
# File 'lib/phpass/md5.rb', line 20 def check(pw, hash) crypt(pw, hash) == hash end |
#hash(pw) ⇒ Object
14 15 16 17 18 |
# File 'lib/phpass/md5.rb', line 14 def hash(pw) rnd = '' rnd = Phpass.random_bytes(6) crypt(pw, gensalt(rnd)) end |