php-7.2

PHP: Strange Array Behaviour After Object Type Casting to Array

陌路散爱 提交于 2019-12-10 18:05:24
问题 When you do array type-casting of json_decode d value (with $assoc = false ), PHP creates an array with string indices: $a = (array)json_decode('{"7":"value1","8":"value2","9":"value3","13":"value4"}'); var_export($a); //array ( // '7' => 'value1', // '8' => 'value2', // '9' => 'value3', // '13' => 'value4', //) And for some reason these indices are not accessible: var_dump(isset($a[7]), isset($a['7'])); //false //false When you try to create the same array by PHP itself, it is being created

Argon2i in PHP7 - Picking Appropriate Options

妖精的绣舞 提交于 2019-12-07 16:38:15
问题 What values should I use for generating Argon2i hashes and how can I find the appropriate settings my hardware can afford? Namely: memory_cost time_cost threads as: $options = [ 'memory_cost' => 1<<17, 'time_cost' => 4, 'threads' => 3, ]; $hash = password_hash('test', PASSWORD_ARGON2I, $options); There is a simple script in PHP docs for finding the appropriate cost value for bcrypt hashes. How can this be fitted for Argon2? 回答1: From: PHP RFC Argon2 password_hash Cost Factors From: Due to the

Argon2i in PHP7 - Picking Appropriate Options

人走茶凉 提交于 2019-12-05 22:13:24
What values should I use for generating Argon2i hashes and how can I find the appropriate settings my hardware can afford? Namely: memory_cost time_cost threads as: $options = [ 'memory_cost' => 1<<17, 'time_cost' => 4, 'threads' => 3, ]; $hash = password_hash('test', PASSWORD_ARGON2I, $options); There is a simple script in PHP docs for finding the appropriate cost value for bcrypt hashes. How can this be fitted for Argon2? From: PHP RFC Argon2 password_hash Cost Factors From: Due to the variety of platforms PHP runs on, the cost factors are deliberately set low as to not accidentally exhaust

PHP 7.2 with mcrypt in Windows

天大地大妈咪最大 提交于 2019-12-04 09:42:05
There are some huge legacy systems whose dependencies on PHPs' mcrypt are extremely important and vital (including the data storage in database). I need to find a way to maintain this library while upgrading to PHP 7.2 (which already worked fine). My local test environment is Windows. The live environment is run on CentOS. Some of the answers I have seen is decrypting and change mcrypt to openssl ( I think that's not possible at the moment since there's a lot of data to decrypt ). Another way lights to download a lower PHP version with mcrypt -support, copy the extension and add it to php.ini

Connecting php 7.2 to MS SQL using sqlsrv

不想你离开。 提交于 2019-12-04 04:35:54
I'm trying to get a connection to MS SQL up and running via PHP on my machine. I'm running IIS, have PHP 7.2 installed and MS SQL Express 2017. I have my basic web page running but when I click to open the PHP page, the connection does not work. session_start(); echo "Hello "; if (isset($_POST['submit'])) { $_SESSION["server"] = $_POST['server']; $_SESSION["database"]= $_POST['database']; $_SESSION["username"] = $_POST['username']; $_SESSION["password"] = $_POST['password']; echo $_SESSION["database"]; //CONNECTION $serverName = $_SESSION["server"]; $connectionInfo["Database"] = $_SESSION[

PHP 7.2.7 warning: Use of undefined constant

眉间皱痕 提交于 2019-12-02 03:01:41
问题 So after I click submit on my index.php resgitration form. It all went good name, email, and password is saved from my database. But there is a warning that irrates me. Use of undefined constant result_query - assumed 'result_query' (this will throw an Error in a future version of PHP) Appears. It said it is in line 26. Here is my code on my function.php where the warning is coming from. <?php include "db.php" ?> <?php function createAccount(){ global $connection; if(isset($_POST['submit'])){

MCrypt rijndael-256 to OpenSSL aes-256-ecb conversion

落爺英雄遲暮 提交于 2019-12-01 05:40:06
Since Mcrypt is deprecated, I want to use OpenSSL instead in my code since we already using php 7.2.4 in our server. I have used following code for Encryption/Decryption. //ENCRYPTION function encrypt($text, $salt='') { if ($text == "") return ""; if ($salt == "") $salt = 'DiAo74dOO09T48YESmuvbS0T'; return trim(base64_encode(mcrypt_encrypt(MCRYPT_RIJNDAEL_256, $salt, $text, MCRYPT_MODE_ECB, mcrypt_create_iv (mcrypt_get_iv_size(MCRYPT_RIJNDAEL_256, MCRYPT_MODE_ECB), MCRYPT_RAND)))); } //DECRYPTION function decrypt($text, $salt = '') { if ($text == "") return ""; if ($salt == "") $salt =

PHP 7.2 - Warning: count(): Parameter must be an array or an object that implements Countable [closed]

こ雲淡風輕ζ 提交于 2019-12-01 03:58:13
I just upgraded my PHP Version from 5.6 to 7.2 . I used count() function in my login page, example: if(!empty($_POST['username']) && !empty($_POST['password'])): $records = $conn->prepare('SELECT id,username,password FROM users WHERE username = :username'); $records->bindParam(':username', $_POST['username']); $records->execute(); $results = $records->fetch(PDO::FETCH_ASSOC); $message = ''; if(count($results) > 0 && password_verify($_POST['password'], $results['password']) ){ $_SESSION['user_id'] = $results['id']; header("Location: /"); } else { $message = 'Sorry, those credentials do not

PHP 7.2 - Warning: count(): Parameter must be an array or an object that implements Countable [closed]

不羁的心 提交于 2019-12-01 00:49:06
问题 Closed. This question is off-topic. It is not currently accepting answers. Want to improve this question? Update the question so it's on-topic for Stack Overflow. Closed last year . I just upgraded my PHP Version from 5.6 to 7.2 . I used count() function in my login page, example: if(!empty($_POST['username']) && !empty($_POST['password'])): $records = $conn->prepare('SELECT id,username,password FROM users WHERE username = :username'); $records->bindParam(':username', $_POST['username']);

How do I use the Argon2 algorithm with password_hash?

◇◆丶佛笑我妖孽 提交于 2019-11-30 11:04:03
问题 So I heard that PHP 7.2 introduced the new Argon2 algorithm. But I'm confused on how I can use it with my existing code. For instance, I have this $password = password_hash('somepassword', PASSWORD_DEFAULT, ['cost' => 12]); Does PASSWORD_DEFAULT now use Argon2? What, if anything, do I need to change with password_verify ? Is bcrypt considered insecure now? 回答1: What is Argon2? Is bcrypt bad now? Prior to PHP 7.2, the only hashing algorithm password_hash used was bcrypt. As of this writing,