]> git.mxchange.org Git - hub.git/commitdiff
Added more debug stuff + $content needs to be a package hash generated for.
authorRoland Haeder <roland@mxchange.org>
Mon, 11 May 2015 23:48:36 +0000 (01:48 +0200)
committerRoland Haeder <roland@mxchange.org>
Mon, 11 May 2015 23:48:36 +0000 (01:48 +0200)
Signed-off-by: Roland Haeder <roland@mxchange.org>
application/hub/main/package/class_NetworkPackage.php

index 46c0e311e5fa8df09d8f3f47e71e4eb326eb00f4..291b8e578e263ae3469a4938adb3fcbe4504b45e 100644 (file)
@@ -659,6 +659,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                );
        
                // 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
@@ -675,6 +676,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
         */
        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]);
 
@@ -700,7 +702,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                //* 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,
@@ -708,8 +710,8 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                        $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
@@ -717,7 +719,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                        // - separator
                        self::PACKAGE_MASK_SEPARATOR,
                        // 4.) Checksum
-                       $this->getHashFromContent($content)
+                       $this->getHashFromContent($compressed)
                );
 
                // Debug message
@@ -729,7 +731,7 @@ class NetworkPackage extends BaseHubSystem implements Deliverable, Receivable, R
                        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