Encrypting password


#1

Hi all

is there any way to encrypt password in ruby like sha1(‘password’) or
md5(‘password’) in PHP?

please help


#2

require ‘digest/sha1’
sha1 = Digest::SHA1.hexdigest(‘something secret’)

Unni K. wrote:

is there any way to encrypt password in ruby like sha1(‘password’) or
md5(‘password’) in PHP?


#3

Thank you for your reply…

But where should i write this.

I have a controller called say_controller.rb

class SayController <ApplicationController

def first

end

def second

end

end

first.rhtml have password field where one can enter their password.

so I have to write

" require ‘digest/sha1’
sha1 = Digest::SHA1.hexdigest(‘something secret’)"

where and how

thanks in advance

Florencio C. wrote:

require ‘digest/sha1’
sha1 = Digest::SHA1.hexdigest(‘something secret’)

Unni K. wrote:

is there any way to encrypt password in ruby like sha1(‘password’) or
md5(‘password’) in PHP?


#4

Hello.

If you want to crypt a password between the client and the server, you
should use SSL between them. SH1 or MD5 encryption, like the one
provided with ruby/php are used to crypt password on the server side.

Tony


#5

Best place would be your user model.

Kind regards
Nicolai