You are here

function backup_migrate_destination_nodesquirrel::_get_hash in Backup and Migrate 6.3

Same name and namespace in other branches
  1. 8.3 includes/destinations.nodesquirrel.inc \backup_migrate_destination_nodesquirrel::_get_hash()
  2. 6.2 includes/destinations.nodesquirrel.inc \backup_migrate_destination_nodesquirrel::_get_hash()
  3. 7.2 includes/destinations.nodesquirrel.inc \backup_migrate_destination_nodesquirrel::_get_hash()

Genrate a hash with a given secret key, timestamp and random value.

1 call to backup_migrate_destination_nodesquirrel::_get_hash()
backup_migrate_destination_nodesquirrel::_sign_request in includes/destinations.nodesquirrel.inc
Genrate a hash with a given secret key, timestamp and random value.

File

includes/destinations.nodesquirrel.inc, line 546
Functions to handle the NodeSquirrel backup destination.

Class

backup_migrate_destination_nodesquirrel
A destination for sending database backups to the NodeSquirel backup service.

Code

function _get_hash($time, $nonce) {
  if ($private_key = $this
    ->_get_private_key()) {
    $message = $time . ':' . $nonce . ':' . $private_key;

    // Use HMAC-SHA1 to authenticate the call.
    $hash = base64_encode(pack('H*', sha1((str_pad($private_key, 64, chr(0x0)) ^ str_repeat(chr(0x5c), 64)) . pack('H*', sha1((str_pad($private_key, 64, chr(0x0)) ^ str_repeat(chr(0x36), 64)) . $message)))));
    return $hash;
  }
  _backup_migrate_message('You must enter a valid secret key to use NodeSquirrel.', array(), 'error');
  return FALSE;
}