Tag: bcrypt

密码validation在两个相反的情况下失败

我正在研究Michael Hartl的Ruby on Rails教程,并产生了一个有趣的困境。 我会做错事,所以我需要你帮忙找到问题。 该问题围绕User模型中的密码属性validation。 该属性的初始validation是: validates :password, presence: true, confirmation: true, length: { minimum: 6 } 这需要最小长度的密码,旨在满足新用户创建其实例的情况。 我已经创建了以下测试(我希望我使用过Rspec!)。 这些测试检查validation是否有效: test “password must not be blank or made up of spaces” do @user.password = @user.password_confirmation = ” ” assert_not @user.valid? end test “password must not be empty/nil” do @user.password = @user.password_confirmation = “” assert_not […]

Windows 10中的bcrypt加载错误

现在我正在尝试在Windows 10中安装bcrypt,但是每当运行webrick服务器时我都会遇到加载错误,如下所示。 C:/Ruby22-x64/lib/ruby/gems/2.2.0/gems/bcrypt-3.1.10-x64-mingw32/lib/bcrypt.rb:16:in `require’: cannot load such file — bcrypt_ext (LoadError) 我使用rails 4.1.5和ruby 2.2.3。 当我使用Windows 8.1时,bcrypt没有问题。 当我使用Windows 8.1时,ruby版本是2.1.6 我该如何解决这个bcrypt问题?

没有这样的文件加载 – bcrypt_ext(通过设计)

我在rails 3上使用devise(当前gem)中的数据库身份validation,并且在尝试使用用户名/密码登录时出现以下错误。 no such file to load — bcrypt_ext This error occurred while loading the following files: bcrypt bcrypt_ext 我之前已经“成功安装了bcrypt-ruby-2.1.2”gem。 有任何想法吗? 我也尝试给bundle服务器git repo地址并获取master,但它没有解决问题。

使用bcrypt生成的Rails密码是否可移植?

我有一个现有的Web应用程序,有几千个用户,我正在移植到Rails。 当我重写和重构这个应用程序时,我可能需要在任意数量的不同服务器上运行它以进行开发,测试和生产。 我在我的用户模型中使用Rails的内置has_secure_password方法,但我担心密码数据的可移植性。 我需要将数据库的内容从一台机器移动到另一台机器,以便在不同的环境中进行测试,并且非常重要的是我可以在每个环境中使用相同的用户和密码集测试用户身份validationfunction。 到目前为止,很容易找到关于bcrypt-ruby如何与Rails has_secure_password一起工作的答案,但经过数周的搜索后,我还没有找到一个明确的答案。 如果has_secure_password导致WorkFactor + Salt + HashedPassword连接并保存到password_digest数据库列,那么如果移动到任何其他计算机(假设任何其他计算机在类Unix操作系统上运行Rails),那么可以重新生成该哈希并进行可靠比较吗? 或者换句话说 – 使用Rails的has_secure_password生成的bcrypt-ruby密码has_secure_password可移植? 跟进问题 :如果盐总是随机生成的(我看到相同的密码使用不同的哈希值,所以我不认为盐是从密码本身的文本创建的)那么Rails应用程序将如何能够可靠地生成在登录表单上重新提交密码,并将其与数据库中的密码进行比较。 显然,为了比较它,它必须首先知道盐是什么。 它是如何做到的?

bcrypt-ruby不会与bundler一起安装,但可以与gem install一起使用

我刚刚开始遇到捆绑包问题 – 在进行捆绑安装或sudo捆绑安装时,bcrypt-ruby将无法安装,并退出时出现以下错误: Installing bcrypt-ruby (2.1.4) with native extensions Gem::Installer::ExtensionBuildError: ERROR: Failed to build gem native extension. /usr/bin/ruby1.8 extconf.rb Gem files will remain installed in /home/deploy/vendor/bundle/ruby/1.8/gems/bcrypt-ruby-2.1.4 for inspection. Results logged to /home/deploy/vendor/bundle/ruby/1.8/gems/bcrypt-ruby-2.1.4/ext/mri/gem_make.out An error occured while installing bcrypt-ruby (2.1.4), and Bundler cannot continue. Make sure that `gem install bcrypt-ruby -v ‘2.1.4’` succeeds before bundling. 但是, […]

Ruby BCrypt哈希比较

我正在尝试使用Sinatra和BCrypt实现看似非常简单的身份validation方法,但很明显我错过了一些东西…… 用户预先分配了一个临时密码,该密码以明文forms存储在数据库中。 我对临时密码进行身份validation,然后创建一个salt和password_hash,并将它们作为字符串写入db(在本例中为mongo)。 要进行身份validation,我从db和用户密码中获取salt进行比较。 post “/password_reset” do user = User.first(:email => params[:email], :temp_password => params[:temp_password]) if dealer != nil then password_salt = BCrypt::Engine.generate_salt password_hash = BCrypt::Engine.hash_secret(params[:password], password_salt) user.set(:password_hash => password_hash) user.set(:password_salt => password_salt) end end post “/auth” do @user = User.first(:email => params[:email]) @user_hash = BCrypt::Password.new(@user.password_hash) #because the password_hash is stored in the db as […]

无法加载此类文件 – 1.9 / bcrypt_ext(LoadError)

嘿,当我尝试启动rails服务器时,我得到以下错误 有任何想法吗? 目前还没有可行的解决方案…… 顺便说一句,我运行Windows 8 ……可能是问题所在:D C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require’: cannot load such file — 1.9/bcry pt_ext (LoadError) from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bcrypt-ruby-3.1.0-x86-mingw32/lib/bcrypt_ext.rb:2:in `’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `block in require’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:236:in `load_dependency’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/activesupport-3.2.11/lib/active_support/dependencies.rb:251:in `require’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bcrypt-ruby-3.1.0-x86-mingw32/lib/bcrypt.rb:12:in `’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `require’ from C:/RailsInstaller/Ruby1.9.3/lib/ruby/gems/1.9.1/gems/bundler-1.3.4/lib/bundler/runtime.rb:72:in `block (2 levels) […]

bcrypt错误:设计ruby 2.0和rails 4.0

当我尝试运行我的应用程序时,我一直收到此错误: C:/ruby-2.0.0-p195-i386-mingw32/lib/ruby/gems/2.0.0/gems/activesupport-4.0.0.rc1 /lib/active_support/dependencies.rb:228:in`requirement’:无法加载此类文件 – 2 .0 / bcrypt_ext(LoadError) 任何接受者? – 我试图使用设计gem进行基本的用户身份validation..

BCrypt说长的,类似的密码是等价的 – 我,gem或密码学领域的问题?

我一直在试验BCrypt,并发现了以下内容。 如果重要的话,我正在运行ruby 1.9.2dev(2010-04-30 trunk 27557)[i686-linux] require ‘bcrypt’ # bcrypt-ruby gem, version 2.1.2 @long_string_1 = ‘f287ed6548e91475d06688b481ae8612fa060b2d402fdde8f79b7d0181d6a27d8feede46b833ecd9633b10824259ebac13b077efb7c24563fce0000670834215’ @long_string_2 = ‘f6ebeea9b99bcae4340670360674482773a12fd5ef5e94c7db0a42800813d2587063b70660294736fded10217d80ce7d3b27c568a1237e2ca1fecbf40be5eab8’ def salted(string) @long_string_1 + string + @long_string_2 end encrypted_password = BCrypt::Password.create(salted(‘password’), :cost => 10) puts encrypted_password #=> $2a$10$kNMF/ku6VEAfLFEZKJ.ZC.zcMYUzvOQ6Dzi6ZX1UIVPUh5zr53yEu password = BCrypt::Password.new(encrypted_password) puts password.is_password?(salted(‘password’)) #=> true puts password.is_password?(salted(‘passward’)) #=> true puts password.is_password?(salted(‘75747373’)) #=> true puts password.is_password?(salted(‘passwor’)) #=> false […]