What PHP 7.2 Brings: Argon2i Hashing, libsodium, and Key Improvements

PHP 7.2 introduces major security upgrades like Argon2i password hashing and built‑in libsodium, removes the outdated mcrypt extension, refines count() behavior, adds object type hints, and fixes hash and array key handling, offering developers a more robust and modern backend language.

21CTO
21CTO
21CTO
What PHP 7.2 Brings: Argon2i Hashing, libsodium, and Key Improvements

PHP is often called “the world’s best language,” and many developers love it; the author is a fan and highlights the new features introduced in PHP 7.2.

Security improvements

PHP 7.2 deprecates the insecure sha1() and md5() functions and encourages the use of password_hash('password', PASSWORD_ARGON2I). The Argon2i algorithm also supports custom options:

$options = [
    'memory_cost' => PASSWORD_ARGON2_DEFAULT_MEMORY_COST,
    'time_cost'   => PASSWORD_ARGON2_DEFAULT_TIME_COST,
    'threads'     => PASSWORD_ARGON2_DEFAULT_THREADS,
];
password_hash('password', PASSWORD_ARGON2I, $options);

The Argon2i algorithm addresses previous hashing weaknesses by requiring higher memory usage.

libsodium is now bundled as a core extension, providing modern cryptographic primitives.

mcrypt removal

The mcrypt extension has been removed because it hindered PHP’s evolution.

Improvements to SSL/TLS constants have also been added.

Language feature enhancements

Calling count() on a scalar now triggers a warning. PHP 7.2 introduces the object type hint for parameters and return types.

The hash extension now uses a HashContext object instead of a resource.

Issues with numeric string keys in arrays and objects have been fixed: keys are automatically cast to the appropriate type, eliminating access problems.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

Backend DevelopmentSecurity7.2Argon2ilibsodium
21CTO
Written by

21CTO

21CTO (21CTO.com) offers developers community, training, and services, making it your go‑to learning and service platform.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.