Home Explore Blog CI



nushell

commands/docs/bits_xor.md
92c46782b4ab46b594d32bceaa61c6909dcfa3e8b9e03a2a0000000300000780
---
title: bits xor
categories: |
  bits
version: 0.104.0
bits: |
  Performs bitwise xor for ints or binary values.
usage: |
  Performs bitwise xor for ints or binary values.
editLink: false
contributors: false
---
<!-- This file is automatically generated. Please edit the command in https://github.com/nushell/nushell instead. -->

# `bits xor` for [bits](/commands/categories/bits.md)

<div class='command-title'>Performs bitwise xor for ints or binary values.</div>

## Signature

```> bits xor {flags} (target)```

## Flags

 -  `--endian, -e {string}`: byte encode endian, available options: native(default), little, big

## Parameters

 -  `target`: Right-hand side of the operation.


## Input/output types:

| input        | output       |
| ------------ | ------------ |
| binary       | binary       |
| int          | int          |
| list\<binary\> | list\<binary\> |
| list\<int\>    | list\<int\>    |
## Examples

Apply bits xor to two numbers
```nu
> 2 | bits xor 2
0
```

Apply bitwise xor to a list of numbers
```nu
> [8 3 2] | bits xor 2
╭───┬────╮
│ 0 │ 10 │
│ 1 │  1 │
│ 2 │  0 │
╰───┴────╯

```

Apply bitwise xor to binary data
```nu
> 0x[ca fe] | bits xor 0x[ba be]
Length: 2 (0x2) bytes | printable whitespace ascii_other non_ascii
00000000:   70 40                                                p@

```

Apply bitwise xor to binary data of varying lengths with specified endianness
```nu
> 0x[ca fe] | bits xor 0x[aa] --endian big
Length: 2 (0x2) bytes | printable whitespace ascii_other non_ascii
00000000:   ca 54                                                ×T

```

Apply bitwise xor to input binary data smaller than the operand
```nu
> 0x[ff] | bits xor 0x[12 34 56] --endian little
Length: 3 (0x3) bytes | printable whitespace ascii_other non_ascii
00000000:   ed 34 56                                             ×4V

```

Chunks
b1668daa (1st chunk of `commands/docs/bits_xor.md`)
Title: bits xor: Bitwise XOR operation for integers and binary values
Summary
The `bits xor` command performs a bitwise XOR operation on integers or binary values. It accepts a target value as input and can handle lists of integers or binary data. The command supports specifying the endianness for binary data and provides examples of its usage with numbers and binary data of varying lengths.