Clear ORM
Search…
BCrypt
We provide helper for storing encrypted password. See example below:
1
class User
2
include Clear::Model
3
primary_key :id, type: :uuid
4
5
column encrypted_password : Crypto::Bcrypt::Password
6
7
def password=(x)
8
self.encrypted_password = Crypto::Bcrypt::Password.create(x)
9
end
10
end
11
12
13
# Create a new user with the password
14
User.create!({password: "helloworld"})
15
16
#...
17
18
# Get the created user
19
user = User.query.first
20
21
if user.encrypted_password.verify("thisisfalse") # < false
22
#...
23
end
24
Copied!
Last modified 1yr ago
Copy link