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.
Dcd590295f2a350045dce2f322b9fc4f?d=identicon&s=25 Unni Krishnan (unnikrishnanes)
on 2007-06-29 12:32
Hi all


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


please help
594e80759429e5f48fa4dc165ec28fbb?d=identicon&s=25 Florencio Cano (fcano)
on 2007-06-29 12:45
require 'digest/sha1'
sha1 = Digest::SHA1.hexdigest('something secret')

Unni Krishnan wrote:

> is there any way to encrypt password in ruby like sha1('password') or
> md5('password') in PHP?
Dcd590295f2a350045dce2f322b9fc4f?d=identicon&s=25 Unni Krishnan (unnikrishnanes)
on 2007-06-29 13: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 Cano wrote:
> require 'digest/sha1'
> sha1 = Digest::SHA1.hexdigest('something secret')
>
> Unni Krishnan wrote:
>
>> is there any way to encrypt password in ruby like sha1('password') or
>> md5('password') in PHP?
59528506e6297141161afcde91d677c9?d=identicon&s=25 Nicolai Reuschling (codeblogger)
on 2007-06-29 13:12
(Received via mailing list)
Best place would be your user model.

Kind regards
Nicolai
99dfa3f52932cfa4dab2a7ae6dd7ef39?d=identicon&s=25 Tony (Guest)
on 2007-06-29 13: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.