Hash algorithm setter

@param string $hashAlgorithm

@return WirecardCEE_Stdlib_Validate_Fingerprint
175915
public function setHashAlgorithm($hashAlgorithm)
    {
        $this->hashAlgorithm = (string) $hashAlgorithm;
        WirecardCEE_Stdlib_Fingerprint::setHashAlgorithm($hashAlgorithm);

        return $this;
    }
424371
public function getFingerprint(string $algorithm = 'SHA1'): Hash {
        $value = openssl_x509_fingerprint(
            $this->getHandle(),
            $algorithm,
            TRUE
        );
        if(!$value) {
            throw new RuntimeException(OpenSSL::getLastError());
        }
        $hash = new Hash($algorithm);
        $hash->setValue($value);
        return $hash;
    }
1332791
public function setSha1($sha1)
    {
        $this->throwExceptionIfProtected();
        if (!is_string($sha1) || preg_match('/[A-Fa-f0-9]{40}/', $sha1) !== 1) {
            throw new \InvalidArgumentException('Specified invalid hash to setSha1()', 1362564220);
        }
        $this->sha1 = strtolower($sha1);
    }
1014458
protected function _algoToCipher(CipherAlgorithmIdentifier $algo): string
    {
        $oid = $algo->oid();
        if (array_key_exists($oid, self::MAP_CIPHER_OID_TO_NAME)) {
            return self::MAP_CIPHER_OID_TO_NAME[$oid];
        }
        if (AlgorithmIdentifier::OID_RC2_CBC == $oid) {
            if (!$algo instanceof RC2CBCAlgorithmIdentifier) {
                throw new \UnexpectedValueException('Not an RC2-CBC algorithm.');
            }
            return $this->_rc2AlgoToCipher($algo);
        }
        throw new \UnexpectedValueException(
            sprintf('Cipher method %s not supported.', $algo->name()));
    }
1178285
public function hash($input) {
		$hash = crypt($input, $this->getSalt());

		if (Utils::binaryStrlen($hash) != $this->getResultLength()) {
			throw new HashException("Error while generating Hash");
		}

		return $hash;
	}
763876
public function setHash($hash)
    {
        if (!is_string($hash)) {
            throw new \InvalidArgumentException(
                'An invalid $hash was passed to Identicon. ' .
                'A binary string was expected.');
        }
        if (strlen($hash) < 6) {
            throw new \InvalidArgumentException(
                'An invalid $hash was passed to Identicon. ' . 
                'The hash was expected to contain at least 6 bytes.');
        }
        
        $this->hash = $hash;
        $this->value = null;
        $this->valueSet = false;
        return $this;
    }
351884
public static CipherAlgorithm getAlgorithmCipher(String encryptAlgorithm) {
	if (encryptAlgorithm==null) { 
		return null;
	}
	switch (encryptAlgorithm) {
		case "aes128": return CipherAlgorithm.aes128;
		case "aes192": return CipherAlgorithm.aes192;
		case "aes256": return CipherAlgorithm.aes256;
		case "des": return CipherAlgorithm.des;
		case "des3": return CipherAlgorithm.des3;
		case "des3_112": return CipherAlgorithm.des3_112;
		case "rc2": return CipherAlgorithm.rc2;
		case "rc4": return CipherAlgorithm.rc4;
		case "rsa": return CipherAlgorithm.rsa;
		default:
			LOG.error("Uknown encryption algorithm: \""+encryptAlgorithm+"\"");
			break;
	}
	return null;
}
4701
private function hashFile($file, $algo)
    {
        if (!file_exists($file)) {
            return false;
        }

        $msg = file_get_contents($file);

        return $this->hash($msg, $algo);
    }
454172
public static function hash($object, $algoOrCtx = 'md5', $raw = FALSE)
	{
		if (is_string($algoOrCtx)) {
			$ctx = hash_init($algoOrCtx);
		} else {
			$ctx = $algoOrCtx;
		}

		if (isset($object->name)) {
			hash_update($ctx, 'name');
			hash_update($ctx, (string)$object->name);
		}

		if (isset($object->insertionPoint)) {
			hash_update($ctx, 'insertionPoint');
			hash_update($ctx, (string)$object->insertionPoint);
		}

		if (isset($object->content)) {
			hash_update($ctx, 'content');
			hash_update($ctx, (string)$object->content);
		}

		if (is_string($algoOrCtx)) {
			return hash_final($ctx, $raw);
		} else {
			return null;
		}
	}
14988
public static byte[] generateSalt() throws NoSuchAlgorithmException {
        SecureRandom random = SecureRandom.getInstance("SHA1PRNG");
        byte[] salt = new byte[8];
        random.nextBytes(salt);
        return salt;
    }
241838
def hash_algo(self, value):
        

        if value not in set(['sha1', 'sha256', 'sha512']):
            raise ValueError(_pretty_message(
                '''
                hash_algo must be one of "sha1", "sha256", "sha512", not %s
                ''',
                repr(value)
            ))

        self._hash_algo = value
1372748
public function hashCode()
    {
        if (null !== $this->getPrimaryKey()) {
            return crc32(serialize($this->getPrimaryKey()));
        }

        return crc32(serialize(clone $this));
    }
338823
public function hasher()
	{
		is_null($this->hasher) and $this->hasher = new \PHPSecLib\Crypt_Hash();

		return $this->hasher;
	}
251691
private function assertValidHashAlgorithm(KeyConfiguration $keyConfig)
    {
        if (!\in_array($keyConfig->getHashAlgorithm(), hash_algos(), true)) {
            throw new UnknownHashAlgorithmException($keyConfig->getHashAlgorithm());
        }
    }
660032
protected function getSupportedHashAlgorithms() : string
    {
        $supportedAlgorithms = hash_algos();

        $algorithms = [];
        foreach ($supportedAlgorithms as $hashAlgo) {
            if (false !== strpos($hashAlgo, ',')) {
                $algorithms[] = "'{$hashAlgo}'";
            } else {
                $algorithms[] = $hashAlgo;
            }
        }

        return implode(',', $algorithms);
    }
628182
public HashAlgorithm getDecodedHashAlgorithm() throws TLVParserException {
        int algorithmId = getDecodedLong().intValue();
        if (HashAlgorithm.isHashAlgorithmId(algorithmId)) {
            return HashAlgorithm.getById(algorithmId);
        }
        throw new TLVParserException("Unknown hash algorithm with id " + algorithmId);
    }
233809
public static function generate(Array $aValues, WirecardCEE_Stdlib_FingerprintOrder $oFingerprintOrder)
    {
        if (self::$_HASH_ALGORITHM == self::HASH_ALGORITHM_HMAC_SHA512) {
            $secret = isset( $aValues['secret'] ) && !empty( $aValues['secret'] ) ? $aValues['secret'] : '';
            if (!strlen($secret)) {
                throw new WirecardCEE_Stdlib_Exception_UnexpectedValueException();
            }
            $hash   = hash_init(self::HASH_ALGORITHM_SHA512, HASH_HMAC, $secret);
        } else {
            $hash = hash_init(self::$_HASH_ALGORITHM);
        }
        foreach ($oFingerprintOrder as $key) {
            $key = (string) $key;

            if (array_key_exists($key, $aValues)) {
                hash_update($hash, ( self::$_STRIP_SLASHES ) ? stripslashes($aValues[$key]) : $aValues[$key]);
            } else {
                throw new WirecardCEE_Stdlib_Exception_InvalidValueException('Value for key ' . strtoupper($key) . ' not found in values array.');
            }
        }

        return hash_final($hash);
    }