/**
* Creates an instance of this Feature class and prepares it for usage
*
- * @param $appInstance A manageable application
* @return $featureInstance An instance of this Feature class
*/
- public final static function createHubcoinRewardFeature (ManageableApplication $appInstance) {
+ public final static function createHubcoinRewardFeature () {
// Get a new instance
$featureInstance = new HubcoinRewardFeature();
* @return $isAvailable Whether this feature is available
*/
public function isFeatureAvailable () {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: CALLED!', __METHOD__, __LINE__));
+
// Testing this feature is pretty simple:
- $isAvailable = (($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === 'Y') && (extension_loaded('scrypt')) && (is_callable('scrypt')));
+ $isAvailable = (($this->getConfigInstance()->getConfigEntry('extension_scrypt_loaded') === TRUE) && (extension_loaded('scrypt')) && (is_callable('scrypt')));
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: isAvailable=%d - EXIT!', __METHOD__, __LINE__, intval($isAvailable)));
// Return status
return $isAvailable;
/**
* Feature method 'generateHash'
*
- * @param
+ * @param $data Data to hash
+ * @return $hash Finished hash
+ */
+ public function featureMethodGenerateHash ($data) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: data()=%d - CALLED!', __METHOD__, __LINE__, strlen($data)));
+
+ // Make sure the feature is available
+ assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward'));
+
+ // Call inner class
+ $hash = Scrypt::hashScrypt($data);
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: hash=%s - EXIT!', __METHOD__, __LINE__, $hash));
+
+ // Return generated hash
+ return $hash;
+ }
+
+ /**
+ * Feature method 'checkHash'
+ *
+ * @param $data Data to check hash for
+ * @param $hash Previously generated hash for valdiation
+ * @return $isValid Whether the given hash matches a new one from given data
+ */
+ public function featureMethodCheckHash ($data, $hash) {
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: data()=%d,hash=%s - CALLED!', __METHOD__, __LINE__, strlen($data), $hash));
+
+ // Make sure the feature is available
+ assert(FrameworkFeature::isFeatureAvailable('hubcoin_reward'));
+
+ // Determine it
+ $isValid = Scrypt::checkScrypt($data, $hash);
+
+ // Debug message
+ //* NOISY-DEBUG: */ self::createDebugInstance(__CLASS__)->debugOutput(sprintf('[%s:%d]: isValid=%d - EXIT!', __METHOD__, __LINE__, intval($isValid)));
+
+ // Return status
+ return $isValid;
+ }
}
// [EOF]