Class: String
- Inherits:
-
Object
- Object
- String
- Defined in:
- lib/postdb/helpers/string.rb
Instance Method Summary collapse
-
#is_crypt?(crypt) ⇒ Boolean
Check if the string is a crypt.
Instance Method Details
#is_crypt?(crypt) ⇒ Boolean
Check if the string is a crypt
Arguments:
crypt: (Symbol)
Example:
>> crypt = "$6$AzeWWlznoLKPRJ1m$MeWkZqWKJp1XD.Jnt66D.Riubq7HT9vrRV0AwFXov2rxyzONR50ULiUFj7Kl6ykmh4EXsmpox8QUr6EUIo3NB0"
>> crypt.is_crypt?(:sha512)
=> true
12 13 14 15 16 17 18 19 20 21 |
# File 'lib/postdb/helpers/string.rb', line 12 def is_crypt?(crypt) case crypt when :sha512 return false unless self =~ /^(\$6\$[a-zA-Z0-9]{16}\$[a-zA-Z0-9\.\/\\]{86})$/ true else false end end |