Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By ParisLiakos on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Issue links:
Description:
As of Drupal 8 cryptographic related functionality has been moved to a new Crypt component.
Removed functions:
- drupal_random_bytes()
- drupal_hmac_base64()
- drupal_hash_base64()
D7
$key = drupal_hash_base64($data);
$key = drupal_hmac_base64($data, $key);
$key = drupal_random_bytes(55);
D8
use Drupal\Component\Utility\Crypt;
$key = Crypt::hashBase64($data);
$key = Crypt::hmacBase64($data, $key);
$key = Crypt::randomBytes(55);
// Returns a URL-safe, base64 encoded string of highly randomized bytes.
$cron_key = Crypt::randomBytesBase64(55);
Impacts:
Module developers