Forum: Ruby on Rails encrypted passwords and fixtures

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.
A2c85dc5ee81b12e3cc0a6522e8d079d?d=identicon&s=25 christopher.k.hall (Guest)
on 2005-12-11 17:08
(Received via mailing list)
maybe i'm not seeing the forest through the trees, but how might i go
about
representing encrypted passwords in fixtures?  should i just encrypt
them at
the CL copy/paste into the fixture?  Not sure if there's a 'proper' way
to
do this.

Thanks.
10d9ed7ab11115b081bb36f56a7a13bc?d=identicon&s=25 John Wilger (Guest)
on 2005-12-11 17:40
(Received via mailing list)
On 12/11/05, Chris Hall <christopher.k.hall@gmail.com> wrote:
> maybe i'm not seeing the forest through the trees, but how might i go about
> representing encrypted passwords in fixtures?  should i just encrypt them at
> the CL copy/paste into the fixture?  Not sure if there's a 'proper' way to
> do this.

You can include eRb tags in your YAML fixture files, so you can
actually do the encryption right in the fixture:

-- BEGIN accounts.yml --
<% require 'sha1' %>
first:
  id: 1
  username: user_one
  password: <%= SHA1::hexdigest 'user_one_password' %>
-- END accounts.yml --

Obviously, modify that for whatever encryption scheme you're using.

--
Regards,
John Wilger
http://johnwilger.com

-----------
Alice came to a fork in the road. "Which road do I take?" she asked.
"Where do you want to go?" responded the Cheshire cat.
"I don't know," Alice answered.
"Then," said the cat, "it doesn't matter."
- Lewis Carrol, Alice in Wonderland
This topic is locked and can not be replied to.