1 bootstrap.inc backdrop_generate_test_ua($prefix)

Generates a user agent string with a HMAC and timestamp for simpletest.

File

core/includes/bootstrap.inc, line 3395
Functions that need to be loaded on every Backdrop request.

Code

function backdrop_generate_test_ua($prefix) {
  static $key;

  if (!isset($key)) {
    // We use the salt from settings.php to make the HMAC key, since the
    // database is not yet initialized and we can't access any Backdrop
    // variables. The file properties add more entropy.
    $key = settings_get('hash_salt') . filectime(__FILE__) . fileinode(__FILE__);
  }
  // Generate a moderately secure HMAC based on the database credentials.
  $salt = uniqid('', TRUE);
  $check_string = $prefix . ';' . time() . ';' . $salt;
  return $check_string . ';' . backdrop_hmac_base64($check_string, $key);
}