简体   繁体   English

在PHP 7.3中使用argon2加密而无需重新编译

[英]Using argon2 encryption in php 7.3 without recompiling

I want to encrypt passwords using argon2 in php 7.3, but the problem is that I have to recompile php with —with-password-argon2 flag. 我想在php 7.3中使用argon2加密密码,但是问题是我必须使用—with-password-argon2标志重新编译php。
The issue is that the current hosting provider doesn't support this. 问题是当前的托管服务提供商不支持此功能。 Is there any way to use argon2 in php without recompiling or should I just use bcrypt? 有什么方法可以在PHP中使用argon2而不进行重新编译,还是应该只使用bcrypt?

Well, there is a polyfill for libsodium , a library for various cryptographic algorithms, and they state : 那么, 一个填充工具libsodium ,各种加密算法库,以及他们陈述

It's not feasible to polyfill scrypt or Argon2 into PHP and get reasonable performance. 将scrypt或Argon2填充到PHP中并获得合理的性能是不可行的。 Users would feel motivated to select parameters that downgrade security to avoid denial of service (DoS) attacks. 用户可能会主动选择降低安全性的参数,以避免拒绝服务(DoS)攻击。

The only winning move is not to play. 唯一的制胜法宝是不参加比赛。

So, no, a pure PHP solution is apparently infeasible. 因此,不,纯粹的PHP解决方案显然是行不通的。 You will need to be able to install some native library in some form or another. 您将需要能够以某种形式或其他形式安装某些本机库。

Since PHP 7.2, Sodium is usually bundled with PHP. 从PHP 7.2开始, Sodium通常与PHP捆绑在一起。 This library provides high-level function for cryptography (encryption, signature, hash,...). 该库提供了用于加密的高级功能(加密,签名,哈希等)。

It provides the sodium_crypto_pwhash_str function ( source ) that uses argon2, and is Sodium is indeed bundled, you shouldn't need to recompile PHP. 它提供了使用argon2的sodium_crypto_pwhash_str函数( source ),并且Sodium确实是捆绑在一起的,因此您无需重新编译PHP。 You should use the parameters given for time and memory options. 您应该使用给定的时间和内存选项参数。 With a moderate security setting I had this output : $argon2id$v=19$m=262144,t=3,p=1$cH0L6kab+fCGHBE3fEw2bw$leS9TBiPOq1gEGg+O6PxAn/O7XXyVnRLs6ANcHHXfCIroot@vps531354: 使用中等安全性设置时,我得到以下输出: $argon2id$v=19$m=262144,t=3,p=1$cH0L6kab+fCGHBE3fEw2bw$leS9TBiPOq1gEGg+O6PxAn/O7XXyVnRLs6ANcHHXfCIroot@vps531354:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM