| 7 bootstrap.inc | drupal_generate_test_ua($prefix) |
| 8 bootstrap.inc | drupal_generate_test_ua($prefix) |
Generates a user agent string with a HMAC and timestamp for simpletest.
3 calls to drupal_generate_test_ua()
File
- core/
includes/ bootstrap.inc, line 2399 - Functions that need to be loaded on every Drupal request.
Code
function drupal_generate_test_ua($prefix) {
global $drupal_hash_salt;
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 Drupal variables.
// The file properties add more entropy not easily accessible to others.
$key = $drupal_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 . ';' . drupal_hmac_base64($check_string, $key);
}
Login or register to post comments