);
// Hash content and sender id together, use scrypt
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $senderId . ',content()=' . strlen($content));
$hash = Scrypt::hashScrypt($senderId . ':' . $content . ':' . $this->determineSenderPrivateKeyHash($data));
// Return it
*/
private function isPackageHashValid (array $decodedArray) {
// Check validity
+ /* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('NETWORK-PACKAGE[' . __METHOD__ . ':' . __LINE__ . ']: senderId=' . $decodedArray[self::PACKAGE_CONTENT_SENDER] . ',message()=' . strlen($decodedArray[self::PACKAGE_CONTENT_MESSAGE]));
//* DEBUG-DIE: */ die(__METHOD__ . ': decodedArray=' . print_r($decodedArray, TRUE));
$isHashValid = Scrypt::checkScrypt($decodedArray[self::PACKAGE_CONTENT_SENDER] . ':' . $decodedArray[self::PACKAGE_CONTENT_MESSAGE] . ':' . $this->determineSenderPrivateKeyHash($decodedArray), $decodedArray[self::PACKAGE_CONTENT_HASH]);
//* DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput('content(' . strlen($content) . ')=' . $content);
// ... and compress it
- $content = $this->getCompressorInstance()->compressStream($content);
+ $compressed = $this->getCompressorInstance()->compressStream($content);
// Add magic in front of it and hash behind it, including BASE64 encoding
$packageContent = sprintf(self::PACKAGE_MASK,
$this->getCompressorInstance()->getCompressorExtension(),
// - separator
self::PACKAGE_MASK_SEPARATOR,
- // 2.) Raw package content, encoded with BASE64
- base64_encode($content),
+ // 2.) Compressed raw package content, encoded with BASE64
+ base64_encode($compressed),
// - separator
self::PACKAGE_MASK_SEPARATOR,
// 3.) Tags
// - separator
self::PACKAGE_MASK_SEPARATOR,
// 4.) Checksum
- $this->getHashFromContent($content)
+ $this->getHashFromContent($compressed)
);
// Debug message
self::PACKAGE_DATA_RECIPIENT => $helperInstance->getRecipientType(),
self::PACKAGE_DATA_CONTENT => $packageContent,
self::PACKAGE_DATA_STATUS => self::PACKAGE_STATUS_NEW,
- self::PACKAGE_DATA_HASH => $this->generatePackageHash($packageContent, $this->getSessionId())
+ self::PACKAGE_DATA_HASH => $this->generatePackageHash($content, $this->getSessionId())
));
// Debug message