标签: bcrypt

无法在 M1 Mac 上安装 bcrypt - Apple Silicon

我无法在我的项目中安装 bcrypt 包。

我的朋友克隆了我项目的完全相同的存储库,它对他有用。

我红色了一些关于python或node-gyp的讨论的讨论,可能与这个问题有关。

我不知道它是否有帮助,但我有:

  • 节点 v16.13.0

  • 8.1.4

  • Mac M1、macOS 蒙特利版本 12.0.1

我也做了一个npm cache clean --force

我在尝试安装 bcrypt 5.0.1 时收到此消息:

yinkyflash@Air-de-Tom backend % npm install bcrypt
npm ERR! code 1
npm ERR! path /Users/yinkyflash/Desktop/Programming/OpenClassrooms/Projet 6/Livrables/TomCharmasson_6_27052021/backend/node_modules/bcrypt
npm ERR! command failed
npm ERR! command sh -c node-pre-gyp install --fallback-to-build
npm ERR! CC(target) Release/obj.target/nothing/../node-addon-api/nothing.o
npm ERR!   LIBTOOL-STATIC Release/nothing.a
npm ERR!   CXX(target) Release/obj.target/bcrypt_lib/src/blowfish.o
npm ERR! Failed to execute '/usr/local/bin/node /usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js build --fallback-to-build --module=/Users/yinkyflash/Desktop/Programming/OpenClassrooms/Projet 6/Livrables/TomCharmasson_6_27052021/backend/node_modules/bcrypt/lib/binding/napi-v3/bcrypt_lib.node --module_name=bcrypt_lib --module_path=/Users/yinkyflash/Desktop/Programming/OpenClassrooms/Projet 6/Livrables/TomCharmasson_6_27052021/backend/node_modules/bcrypt/lib/binding/napi-v3 --napi_version=8 …
Run Code Online (Sandbox Code Playgroud)

macos bcrypt node.js npm apple-m1

3
推荐指数
1
解决办法
1万
查看次数

存储bcrypt哈希值

根据PHP的文档,bcrypt salt是由

"$ 2a $",两位数的成本参数"$",以及字母"./0-9A-Za-z"中的22位数字

因此,如果我使用crypt()函数来哈希我的密码,结果输出包括前七个字符($ 2a $ 10 $,如果10是成本参数)作为盐的一部分 - 并且,根据所有示例我能够在互联网上找到这个完整的输出写入db.

我想知道将剩下的盐和加密数据存储在第一个字符的重点是什么.他们的意思对我来说是完全清楚的,但是我无法理解为什么这些信息应该与哈希的其余部分一起编写.它们不是关于算法的"正义"信息和计算的自适应成本吗?那么存储此类与应用程序相关的信息有什么好处?并且(即使可能听起来很幼稚)为什么要将它们泄露给最终可以抓住我的数据库的攻击者呢?

php hash crypt bcrypt password-storage

2
推荐指数
1
解决办法
2288
查看次数

在CakePHP 2.3中使用bcrypt

我注意到在CakePHP的3.2版本中,他们使用bcrypt添加了对散列的支持.我想利用这个,但我似乎无法找到如何正确使用它.

在我的User模型beforeSave()方法我这样做:

if(isset($this->data[$this->alias]['password'])) {
    $this->data[$this->alias]['password'] = Security::hash($this->data[$this->alias]['password'], 'blowfish');
    unset($this->data['User']['passwd']);
}
Run Code Online (Sandbox Code Playgroud)

它成功地在数据库中为用户帐户保存了bcrypt哈希.但是,我不确定我是如何登录用户的.我的用户控制器具有以下登录操作:

public function login() {
    if($this->request->is('post')) {
        if($this->Auth->login()) {
            $this->redirect($this->Auth->redirect());
        } else {
            $this->Session->setFlash('Invalid username or password, try again.');
        }
    }
}
Run Code Online (Sandbox Code Playgroud)

但它每次都说"用户名或密码无效",我确定这是正确的电子邮件/密码.我认为这是因为AuthComponent不知道它应该使用bcrypt,但我不确定.

有什么建议?

php cakephp bcrypt

2
推荐指数
1
解决办法
1933
查看次数

PHP password_hash(): Are password hashes portable between systems?

我相信使用PHP的password_hash()函数散列的密码可能会转移到不同的系统,并且仍然可以成功地用于验证目的。

据我了解,bcrypt哈希包含所有必要的组件,当与纯文本密码结合使用时,可以验证给定的密码。因此,哈希可以带到具有兼容实现的任何系统中,并用于验证目的。

我将很快尝试一下,但是在此之前,我想知道我的理论是否正确。

它是否正确?

php bcrypt php-password-hash

2
推荐指数
1
解决办法
522
查看次数

节点bcrypt安装有问题

我正在学习sails.js.所以我只想用节点模块bcrypt加密密码.

npm install bcrypt 是我用来安装bcrypt模块的命令,我才知道它有很多依赖项,我也安装了node-gyp npm install -g node-gyp

任何人都可以建议我如何解决它?

错误:

npm install bcryptC:\ WINDOWS\Microsoft.NET \框架\ v4.0.30319\msbuild.exe npm install -g node-gyp

bcrypt node.js npm sails.js

2
推荐指数
1
解决办法
5516
查看次数

使用带有Spring Security Grails插件的BCrypt密码哈希

我正在尝试在使用Spring Security插件的Grails应用程序中使用BCrypt密码哈希.我通过添加以下内容启用了BCryptConfig.groovy

grails.plugins.springsecurity.password.algorithm = 'bcrypt'
Run Code Online (Sandbox Code Playgroud)

我已经定义了以下编解码器来简化使用BCrypt来编码密码:

public class PasswordCodec {

    // it doesn't seem to be possible to dependency-inject codecs, so lookup the bean ourselves
    @Lazy
    private static PasswordEncoder passwordEncoder = Holders.grailsApplication.mainContext.getBean('passwordEncoder')

    static encode = { str ->
        passwordEncoder.encodePassword(str.toString(), null)
    }
}
Run Code Online (Sandbox Code Playgroud)

当我在开发模式下启动应用程序时,数据库会使用几个帐户进行自举(每个帐户都有相同的密码,例如

3.times { i ->
    def username = "user$i"
    def password = "secret".encodeAsPassword()

    new User(username: username, password: password).save()
    // also assign the user a role
}
Run Code Online (Sandbox Code Playgroud)

如果我查看数据库,我看到每个用户密码的编码值是不同的!因此,当用户尝试登录并输入"秘密"密码时,BCrypt编码的密码值与数据库中保存的密码值不匹配也就不足为奇了,因为似乎字符串的BCrypt编码值会发生某种变化随着时间的推移.

显然我在这里做错了,但我不知道是什么?

grails spring-security bcrypt grails-plugin

2
推荐指数
1
解决办法
2976
查看次数

BCrypt比较两个哈希不相等

我有这个代码:

你:= models.Users {}

你= u.FindByEmail(login.Email)

密码:= []字节(login.Password)

hashedPassword,err:= bcrypt.GenerateFromPassword(password,bcrypt.DefaultCost)if err!= nil {panic(err)}

err = bcrypt.CompareHashAndPassword(hashedPassword,[] byte(u.Password))fmt.Println(err)

我最终收到此错误:crypto/bcrypt:hashedPassword不是给定密码的哈希值

但是我之前保存的模型与"admin"具有相同的哈希值,但是当我运行我的应用程序时,它告诉我它不相等.

passwords hash go bcrypt

2
推荐指数
1
解决办法
3015
查看次数

Ubuntu和bcrypt

当我尝试运行此命令时:

gem install bcrypt -v '3.1.10'
Run Code Online (Sandbox Code Playgroud)

之后,我收到此错误:

current directory: /usr/local/rvm/gems/ruby-2.3.0@app2/gems/bcrypt-3.1.10/ext/mri
make "DESTDIR="
compiling bcrypt_ext.c
compiling crypt_blowfish.c
compiling wrapper.c
compiling crypt.c
compiling crypt_gensalt.c
linking shared-object bcrypt_ext.so
/usr/bin/ld: cannot find -lgmp
collect2: error: ld returned 1 exit status
make: *** [bcrypt_ext.so] Error 1

make failed, exit code 2
Run Code Online (Sandbox Code Playgroud)

我做了什么来解决这个问题:

  1. 通过rvm重新安装ruby
  2. 更新和安装的包:
sudo apt-get update

sudo apt-get install curl zlib1g-dev build-essential libssl-dev libreadline-dev libyaml-dev libsqlite3-dev libxml2-dev libxslt1-dev libcurl4-openssl-dev python-software-properties libffi-dev make g++ gcc
Run Code Online (Sandbox Code Playgroud)

之后,仍然会得到同样的错误

我的环境:

vagrant@vagrant-ubuntu-trusty-64:/vagrant$ lsb_release -r
Release:    14.04
vagrant@vagrant-ubuntu-trusty-64:/vagrant$ ruby -v …
Run Code Online (Sandbox Code Playgroud)

ruby ubuntu bcrypt vagrant

2
推荐指数
1
解决办法
1062
查看次数

在轨道上加密红宝石

嗨,我是Bcrypt的新手,我想知道如何正确使用此gem,到目前为止,我已经能够对密码进行哈希处理,但是在将其与用户输入的密码进行比较时,它不匹配。

这是我用于加密和登录的代码。

def self.login(user)
    hashed_password = encrypt_password(user["password"])
    result = User.where({:username => user["username"], :password => hashed_password})
    return result
end

def self.add_user(user)
    hashed_password = encrypt_password(user["password"])
    result = User.create({:username => user["username"],
        :password => hashed_password,
        :firstname => user["firstname"],
        :middle_initial => user["middle_initial"],
        :lastname => user["lastname"],
        :advisory_class => user["advisory_class"]})
    return result
end

def self.encrypt_password(password)
    password_salt = BCrypt::Engine.generate_salt
    password_hash = BCrypt::Engine.hash_secret(password,password_salt)
end
Run Code Online (Sandbox Code Playgroud)

在add_user中,使用登录功能登录时,我正在使用crypto_password功能对其进行加密。密码与数据库中加密的密码不匹配。即时消息,我确定自己的做法不正确,您能指出我做错了什么吗?谢谢。

ruby ruby-on-rails bcrypt

2
推荐指数
1
解决办法
1728
查看次数

如何检查Laravel Hash是否有字符串?

在我使用Laravel 5.1的项目中,除了Hash默认类之外,我还使用我的库来加密密码.那么我怎样才能检查Laravel Hash是否有一个字符串?示例:

$ 2Y $ 10 $ ug8B6Pxs546eQBNICxsEOOH3NgpXjOIo.g4rf1FPZk2xJncWcFUpu

谢谢你的帮助.

php regex bcrypt laravel laravel-5

2
推荐指数
1
解决办法
1683
查看次数