class String
Public Instance Methods
is_crypt?(crypt)
click to toggle source
Check if the string is a crypt
Arguments:
crypt: (Symbol)
Example:
>> crypt = "$6$AzeWWlznoLKPRJ1m$MeWkZqWKJp1XD.Jnt66D.Riubq7HT9vrRV0AwFXov2rxyzONR50ULiUFj7Kl6ykmh4EXsmpox8QUr6EUIo3NB0" >> crypt.is_crypt?(:sha512) => true
# 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