# Validations over hashed password

**URL:** <https://www.ruby-forum.com/t/validations-over-hashed-password/124008>\
**Category:** Rails\
**Created:** [December 23, 2007, 11:37am UTC](https://www.ruby-forum.com/t/validations-over-hashed-password/124008 "2007-12-23T11:37:06Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![vapor](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/5e9695/32.png) [@vapor](https://www.ruby-forum.com/u/vapor)\
**Post date:** [December 23, 2007, 11:37am UTC](https://www.ruby-forum.com/t/validations-over-hashed-password/124008/1 "2007-12-23T11:37:06Z")

</div>

I have this method in user.rb that automatically converts password to  
SHA1 hash

```
def password=(value)
    write_attribute("password", Digest::SHA1.hexdigest(value))
end

```

but my user model validations dont seem to work properly…for example  
length\_of and confirmation\_of… cause it gets SHA1 and stuff…

how do I keep it encrypted yet keep validations too?

if I remove the above mentioned method, it works fine but I risk the  
password being naked 😕
