public static function crypt(string $input, string $password, string $algo = 'sha512'): string
    {
        $chunks = \str_split($input, Str::hashSize($algo));

        $length = Str::strlen($input);
        
        foreach ($chunks as $i => &$chunk) {
            $chunk = $chunk ^ \hash_hmac($algo, $password . $length, $i, true);
        }

        return \implode($chunks);
    }
public static function crypt(string $input, string $password, string $algo = 'sha512'): string
    {
        $chunks = \str_split($input, Str::hashSize($algo));

        $length = Str::strlen($input);
        
        foreach ($chunks as $i => &$chunk) {
            $chunk = $chunk ^ \hash_hmac($algo, $password . $length, $i, true);
        }

        return \implode($chunks);
    }
public static function crypt ( string $ input , string $ password , string $ algo = 'sha512' ) : string { $ chunks = \ str_split ( $ input , Str :: hashSize ( $ algo ) ) ; $ length = Str :: strlen ( $ input ) ; foreach ( $ chunks as $ i => & $ chunk ) { $ chunk = $ chunk ^ \ hash_hmac ( $ algo , $ password . $ length , $ i , true ) ; } return \ implode ( $ chunks ) ; }
Encrypt or decrypt a binary input string.

@param string $input    Input data to encrypt
@param string $password Encryption/decryption key to use on input
@param string $algo     Hashing algo to generate keystream
@return string
Encrypt or decrypt a binary input string .