Generates hash keys.

@param string|null $hashPassword
@param string|null $iv

@return array
503835
private function _roundKeys($hashPassword = null, $iv = null)
    {
        $roundKeys = [];
        $prevKey = $this->_encrypt($this->key, $hashPassword, $iv);
        for ($i = 1; $i <= $this->rounds; $i++) {
            $prevKey = $this->_encrypt($prevKey, $hashPassword, $iv);
            $roundKeys[$i] = substr(DataConverter::rawToBin($prevKey), -1 * $this->sideSize);
        }

        return $roundKeys;
    }
687649
public function generateHash($class, $username, $password, $expires)
    {
        return hash('sha256', $class . $username . $password . $expires . $this->secret);
    }
1266589
public function decrypt($data, $key = null, $iv = null)
    {
        $key = $key === null ? $this->privateKey : $key;

        if (strpos($data, ':') !== false) {
            list($hmac, $pbkdf2Salt, $ivFromData, $encrypted) = explode(':', $data);

            $hmac = base64_decode($hmac);
            $pbkdf2Salt = base64_decode($pbkdf2Salt);
            $ivFromData = base64_decode($ivFromData);
            $encrypted = base64_decode($encrypted);

            $iv = $iv ?: $ivFromData;

            $this->derivateSecureKeys($key, $pbkdf2Salt);

            $calculatedHmac = $this->hmac($pbkdf2Salt . $iv . $encrypted);

            if (!$this->equalHashes($calculatedHmac, $hmac)) {
                throw new \RuntimeException('HMAC ERROR: Invalid HMAC.');
            }
        } else {
            // For 3.1 and older legacy
            $data = base64_decode($data);

            if (!$iv) {
                $ivSize = $this->getIVSize();

                $iv = substr($data, 0, $ivSize);

                $encrypted = substr($data, $ivSize);
            } else {
                $ivSize = $this->getIVSize();

                if (substr($data, 0, $ivSize) === $iv) {
                    $encrypted = substr($data, $ivSize);
                } else {
                    $encrypted = $data;
                }
            }
        }

        $key = CryptHelper::repeatToLength($key, 24, true);

        // Decrypt the data.
        return trim($this->doDecrypt($encrypted, $key, $iv));
    }
200001
public function decrypt($data, $key = null, $iv = null)
    {
        $data = base64_decode($data);

        if (!$iv) {
            $iv = substr($data, 0, static::DEFAULT_RANDOM_BYTE_LENGTH);

            $data = substr($data, static::DEFAULT_RANDOM_BYTE_LENGTH);
        } else {
            if (substr($data, 0, strlen($iv)) === $iv) {
                $data = substr($data, strlen($iv));
            }
        }

        $key = sha1($iv . $key);

        return $this->doDecrypt($data, $key);
    }
243382
public function tokenize($iv, $string = '')
    {
        if (empty($string)) {
            $string = $this->random_string();
        }

        return openssl_encrypt($string, 'AES-256-CBC', $this->_config->get('token'), 0, $iv);
    }
1080687
private String generateHash(String secret) {

		//check for any null values and set them to empty string for hashing
		String timeStamp = null == this.timeStamp ? "" : this.timeStamp;
		String merchantId = null == this.merchantId ? "" : this.merchantId;
		String orderId = null == this.orderId ? "" : this.orderId;
		String result = null == this.result ? "" : this.result;
		String message = null == this.message ? "" : this.message;
		String pasRef = null == this.pasRef ? "" : this.pasRef;
		String authCode = null == this.authCode ? "" : this.authCode;

		//create String to hash
		String toHash = new StringBuilder().append(timeStamp)
				.append(".")
				.append(merchantId)
				.append(".")
				.append(orderId)
				.append(".")
				.append(result)
				.append(".")
				.append(message)
				.append(".")
				.append(pasRef)
				.append(".")
				.append(authCode)
				.toString();

		return GenerationUtils.generateHash(toHash, secret);
	}
17363
public function encrypt($data, $key = null, $iv = null)
    {
        $iv = $iv ?: $this->getRandomKey(static::DEFAULT_RANDOM_BYTE_LENGTH);

        $key = sha1($iv . $key);

        return base64_encode($iv . $this->doEncrypt($data, $key));
    }
805051
public static function passwordReHash($password = '', $hash = '')
    {
        if (self::verifyPassword($password, $hash)) {
            if (password_needs_rehash($hash, self::ALGORITHM_DEFAULT)) {
                return self::createPassword($password);
            }
        }

        return NULL;
    }
568143
public function generateHash(AbstractRequest $request, $securityKey)
    {
        $hashString = '';
        $requestData = $request->toArray();
        sort($this->hashParameters);
        foreach ($this->hashParameters as $key) {
            if (!array_key_exists($key, $requestData)) {
                continue;
            }
            $hashString .= $requestData[$key];
        }
        $hashString .= $securityKey;

        return $this->hashProvider->hash($hashString);
    }
679801
public function decryptData(string $sessionKey, string $iv, string $encrypted): array
    {
        $decrypted = AES::decrypt(
            base64_decode($encrypted, false), base64_decode($sessionKey, false), base64_decode($iv, false)
        );

        $decrypted = json_decode($this->pkcs7Unpad($decrypted), true);

        if (!$decrypted) {
            throw new DecryptException('The given payload is invalid.');
        }

        return $decrypted;
    }
777230
public static function encryptOpenssl($textToEncrypt, string $secretHash = null, string $password = ''): ? string
  {
    if ( !$secretHash ){
      $secretHash = self::$salt;
    }
    if ( $length = openssl_cipher_iv_length(self::$method) ){
      $iv = substr(md5(self::$prefix.$password), 0, $length);
      return openssl_encrypt($textToEncrypt, self::$method, $secretHash, true, $iv);
    }
    return null;
  }
1191821
public static String createHash(char[] password) throws NoSuchAlgorithmException, InvalidKeySpecException {

    final SecureRandom random = new SecureRandom();
    final byte[] salt = new byte[SALT_BYTES];
    random.nextBytes(salt);

    final byte[] hash = pbkdf2(password, salt, PBKDF2_ITERATIONS, HASH_BYTES);
    // format iterations:salt:hash
    return PBKDF2_ITERATIONS + ":" + toHex(salt) + ":" + toHex(hash);
  }
725105
public function decrypt($message, $key, $iv)
    {
        if (!empty($message)) {
            mcrypt_generic_init($this->module, $key, $iv);
            $message = mdecrypt_generic($this->module, $message);
            mcrypt_generic_deinit($this->module);
        }

        return rtrim($message, "\0");
    }
225060
public function getPassword() : IHashedPassword
    {
        return new class implements IHashedPassword
        {
            /**
             * Gets the hashed password string.
             *
             * @return string
             */
            public function getHash() : string
            {
                // TODO: Implement getHash() method.
            }

            /**
             * Gets the hashing algorithm.
             *
             * @return string
             */
            public function getAlgorithm() : string
            {
                // TODO: Implement getAlgorithm() method.
            }

            /**
             * Gets the hashing cost factor.
             *
             * @return int
             */
            public function getCostFactor() : int
            {
                // TODO: Implement getCostFactor() method.
            }

            /**
             * Returns an associated array of the values indexed by the property names.
             *
             * This returns all properties regardless of accessibility.
             *
             * @return array
             */
            public function toArray() : array
            {
                // TODO: Implement toArray() method.
            }

            /**
             * Sets the properties of the object.
             *
             * The property types and structure are NOT validated in any way
             * and as such this should only be used for restoring object
             * state from a persistence store which is in a valid state.
             *
             * @param array $properties
             *
             * @return void
             */
            public function hydrate(array $properties)
            {
                // TODO: Implement hydrate() method.
            }
        };
    }
559030
public static byte[] hashPassword(String password) throws InvalidKeyException, NoSuchAlgorithmException {

        PasswordEncryptor encryptor = new PasswordEncryptor();
        return encryptor.generateEncryptedPassword(password, null, PasswordEncryptor.MD4, null, null);
    }
795168
public function hashPassword($password, $staticSalt = null)
    {
        $dynamicSalt = UtilityAlgorithms::generateRandomString(22, 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789./');
        return crypt($password, '$2a$' . $this->cost . '$' . $dynamicSalt);
    }
571093
public function hashCode()
    {
        $validPk = null !== $this->getStructureNodeId() &&
            null !== $this->getParentId();

        $validPrimaryKeyFKs = 2;
        $primaryKeyFKs = [];

        //relation structure_node_parent_fk_node to table kk_trixionary_structure_node
        if ($this->aStructureNodeRelatedByStructureNodeId && $hash = spl_object_hash($this->aStructureNodeRelatedByStructureNodeId)) {
            $primaryKeyFKs[] = $hash;
        } else {
            $validPrimaryKeyFKs = false;
        }

        //relation structure_node_parent_fk_parent to table kk_trixionary_structure_node
        if ($this->aStructureNodeRelatedByParentId && $hash = spl_object_hash($this->aStructureNodeRelatedByParentId)) {
            $primaryKeyFKs[] = $hash;
        } else {
            $validPrimaryKeyFKs = false;
        }

        if ($validPk) {
            return crc32(json_encode($this->getPrimaryKey(), JSON_UNESCAPED_UNICODE));
        } elseif ($validPrimaryKeyFKs) {
            return crc32(json_encode($primaryKeyFKs, JSON_UNESCAPED_UNICODE));
        }

        return spl_object_hash($this);
    }