X-Git-Url: https://git.mxchange.org/?p=core.git;a=blobdiff_plain;f=inc%2Fclasses%2Fmain%2Fcrypto%2Fclass_CryptoHelper.php;h=52bd668a9f9d83d314fb65234d78fd90ca09fd39;hp=61df314948539b8df5a9d01658b16b14b409ab46;hb=eb0b6976151d8996bcf14300e592f36c04e6681c;hpb=a1362d15b7639c7ae2228c020d94ba98c9448ea0 diff --git a/inc/classes/main/crypto/class_CryptoHelper.php b/inc/classes/main/crypto/class_CryptoHelper.php index 61df3149..52bd668a 100644 --- a/inc/classes/main/crypto/class_CryptoHelper.php +++ b/inc/classes/main/crypto/class_CryptoHelper.php @@ -140,9 +140,10 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { * * @param $str Unhashed string * @param $oldHash A hash from previous hashed string + * @param $withFixed Whether to include a fixed salt (not recommended in p2p applications) * @return $hashed The hashed and salted string */ - public function hashString ($str, $oldHash = '') { + public function hashString ($str, $oldHash = '', $withFixed = true) { // Cast the string $str = (string) $str; @@ -160,11 +161,20 @@ class CryptoHelper extends BaseFrameworkSystem implements Cryptable { // Hash the password with salt //* DEBUG: */ echo "salt=".$salt."/plain=".$str."
\n"; - $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_mask'), - $salt, - $this->getRngInstance()->getFixedSalt(), - $str - )); + if ($withFixed === true) { + // Use additional fixed salt + $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_salt_mask'), + $salt, + $this->getRngInstance()->getFixedSalt(), + $str + )); + } else { + // Use salt+string to hash + $hashed = $salt . md5(sprintf($this->getConfigInstance()->getConfigEntry('hash_normal_mask'), + $salt, + $str + )); + } // And return it return $hashed;