1234567891011121314151617181920212223242526 |
- CRYPT_MAKE_SALT_AID = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./"
- def crypt_make_salt
- c1 = CRYPT_MAKE_SALT_AID[rand(CRYPT_MAKE_SALT_AID.length)]
- c2 = CRYPT_MAKE_SALT_AID[rand(CRYPT_MAKE_SALT_AID.length)]
- return c1 + c2
- end
- def crypt(pass, salt = nil)
- salt = crypt_make_salt unless salt
- return pass.to_s.crypt(salt)
- end
- def crypt_challenge?(trypass, hash)
- salt = hash[0, 2]
- tryhash = trypass.to_s.crypt(salt)
- return tryhash == hash
- end
|