public static function xorStrings(string $left, string $right): string
    {
        $length = Binary::safeStrlen($left);
        if ($length !== Binary::safeStrlen($right)) {
            throw new InvalidType(
                'Both strings must be the same length'
            );
        }
        if ($length < 1) {
            return '';
        }
        return (string) ($left ^ $right);
    }
public static function xorStrings(string $left, string $right): string
    {
        $length = Binary::safeStrlen($left);
        if ($length !== Binary::safeStrlen($right)) {
            throw new InvalidType(
                'Both strings must be the same length'
            );
        }
        if ($length < 1) {
            return '';
        }
        return (string) ($left ^ $right);
    }
public static function xorStrings ( string $ left , string $ right ) : string { $ length = Binary :: safeStrlen ( $ left ) ; if ( $ length !== Binary :: safeStrlen ( $ right ) ) { throw new InvalidType ( 'Both strings must be the same length' ) ; } if ( $ length < 1 ) { return '' ; } return ( string ) ( $ left ^ $ right ) ; }
Calculate A xor B, given two binary strings of the same length.

Uses pack() and unpack() to avoid cache-timing leaks caused by
chr().

@param string $left
@param string $right
@return string
@throws InvalidType
Calculate A xor B given two binary strings of the same length .