Forum: Ruby on Rails Encrypting password

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Unni K. (Guest)
on 2007-06-29 14:32
Hi all


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


please help
Florencio C. (Guest)
on 2007-06-29 14:45
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?
Unni K. (Guest)
on 2007-06-29 15:05
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?
Nicolai R. (Guest)
on 2007-06-29 15:12
(Received via mailing list)
Best place would be your user model.

Kind regards
Nicolai
Tony (Guest)
on 2007-06-29 15:36
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
This topic is locked and can not be replied to.