[#create
用于散列机密,返回BCrypt::Password
实例,即加密
我目前正在使用Ruby,但无法获得,之间有什么区别>>
def create_hash_digest(password) BCrypt::Password.create(password) end def verify_hash_digest(password) BCrypt::Password.new(password) end
此示例摘自有关完整的Ruby on Rails的Udemy课程
[我目前正在使用Ruby,但无法获得,def create_hash_digest(password)BCrypt :: Password.create(password)end def verify_hash_digest(password)BCrypt :: ...有什么区别?]] >
[#create
用于散列机密,返回BCrypt::Password
实例,即加密
[#new
用于使用存储的哈希中的数据解密BCrypt::Password
实例。
include BCrypt
# hash a user's password
@password = Password.create("my grand secret")
@password #=> "$2a$12$C5.FIvVDS9W4AYZ/Ib37YuWd/7ozp1UaMhU28UKrfSxp2oDchbi3K"
# store it safely @user.update_attribute(:password, @password)
# read it back
@user.reload!
@db_password = Password.new(@user.password)
# compare it after retrieval
@db_password == "my grand secret" #=> true
@db_password == "a paltry guess" #=> false
#create
将您的密码转换为哈希:
'my_password' ~> '$2a$12$C5.FIvVDS9W4AYZ/Ib37...'
[#new
转换回它时。
[#create
用于散列机密,返回BCrypt::Password
实例,即加密
#create
将您的密码转换为哈希:
'my_password' ~> '$2a$12$C5.FIvVDS9W4AYZ/Ib37...'