# Encrypted passwords and fixtures

**URL:** <https://www.ruby-forum.com/t/encrypted-passwords-and-fixtures/49979>\
**Category:** Rails\
**Created:** [December 11, 2005, 5:08pm UTC](https://www.ruby-forum.com/t/encrypted-passwords-and-fixtures/49979 "2005-12-11T17:08:39Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![christopher.k.hall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bbe5ce/32.png) [@christopher.k.hall](https://www.ruby-forum.com/u/christopher.k.hall)\
**Post date:** [December 11, 2005, 5:08pm UTC](https://www.ruby-forum.com/t/encrypted-passwords-and-fixtures/49979/1 "2005-12-11T17:08:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![christopher.k.hall](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/bbe5ce/32.png) [@christopher.k.hall](https://www.ruby-forum.com/u/christopher.k.hall)\
**Post date:** [December 11, 2005, 5:40pm UTC](https://www.ruby-forum.com/t/encrypted-passwords-and-fixtures/49979/2 "2005-12-11T17:40:29Z")

</div>

On 12/11/05, Chris H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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 W.

> **[John Wilger](http://johnwilger.com)**
>
> The personal website of John Wilger; Dad, Cyclist, Software Developer

* * *

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
