lib/vmail/account.rb
# Hash the password using the given salt. If no salt is supplied, use a new
# one.
Hash the password using the given salt. If no salt is supplied, use a new
one.
Hash the password using the given salt . If no salt is supplied use a new one .
def encode_password(plaintext, salt=generate_salt)
			raise ArgumentError.new("Password must not be nil") if plaintext.nil?
			raise ArgumentError.new("Password must be at least 4 characters") if plaintext.size < 4
			raise ArgumentError.new("Salt must not be nil") if salt.nil?
			raise ArgumentError.new("Salt must be at least 8 characters") if salt.size < 8
			ssha = Digest::SHA1.digest(plaintext+salt) + salt
			return "{SSHA}" + Base64.strict_encode64(ssha).chomp
		end
def encode_password ( plaintext , salt = generate_salt ) raise ArgumentError . new ( "Password must not be nil" ) if plaintext . nil? raise ArgumentError . new ( "Password must be at least 4 characters" ) if plaintext . size < 4 raise ArgumentError . new ( "Salt must not be nil" ) if salt . nil? raise ArgumentError . new ( "Salt must be at least 8 characters" ) if salt . size < 8 ssha = Digest :: SHA1 . digest ( plaintext + salt ) + salt return "{SSHA}" + Base64 . strict_encode64 ( ssha ) . chomp end
Hash the password using the given salt.
Hash the password using the given salt .
plaintext
<not_specific>
salt
<not_specific>
generate_salt
<not_specific>