Forum: Ruby on Rails Encrypt passwords in the database

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.
Lakridserne (Guest)
on 2009-05-09 19:17
(Received via mailing list)
Hi,

I know that there is a way to encrypt passwords, but what would be the
easiest?
For example you have 2 functions in php. You use them by calling:

fuction("data-to-be-encrypted-here");

But is there a similar way in ruby on rails?
Franco C. (Guest)
on 2009-05-09 19:38
(Received via mailing list)
You can use one of the Ruby digest package:
http://www.ruby-doc.org/stdlib/libdoc/digest/rdoc/index.html

For example, if you want to digest a password with SHA 512:

require 'digest/sha2'

Digest::SHA2.hexdigest('password', 512)

Regards.

Franco C..
Lakridserne (Guest)
on 2009-05-13 00:54
(Received via mailing list)
Thanks. I looked at it, but could not understand it. I will use md5
because I also use it in my PHP-applications, and I can therefore use
the same data without reset users passwords and so on. Can I do that
and how?
Franco C. (Guest)
on 2009-05-13 07:27
(Received via mailing list)
Is the same thing:

require 'digest'

Digest::MD5.hexdigest('password')

You need to know how to read an API, you must use it every day ... The
"always open" are:

http://www.ruby-doc.org/core/ and http://api.rubyonrails.org/

Expend a while figuring it out.

Regards.

Franco C..
Lakridserne (Guest)
on 2009-05-13 08:36
(Received via mailing list)
Thanks that helped
This topic is locked and can not be replied to.