function backup_migrate_destination_nodesquirrel::_get_hash

nittany7 destinations.nodesquirrel.inc backup_migrate_destination_nodesquirrel::_get_hash($time, $nonce)

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 modules/contrib/backup_migrate/includes/destinations.nodesquirrel.inc
Genrate a hash with a given secret key, timestamp and random value.

File

modules/contrib/backup_migrate/includes/destinations.nodesquirrel.inc, line 467
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(0x00)) ^ (str_repeat(chr(0x5c), 64))) . pack('H*', sha1((str_pad($private_key, 64, chr(0x00)) ^ (str_repeat(chr(0x36), 64))) . $message)))));
    return $hash;
  }
  _backup_migrate_message('You must enter a valid private key to use NodeSquirrel.', array(), 'error');
  return FALSE;
}