Nushell
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
Get Nu!
Getting Started
  • The Nushell Book
  • Command Reference
  • Cookbook
  • Language Reference Guide
  • Contributing Guide
Blog
  • English
  • 中文
  • Deutsch
  • Français
  • Español
  • 日本語
  • Português do Brasil
  • Русский язык
GitHub
  • Categories

    • Bits
    • Bytes
    • Chart
    • Conversions
    • Core
    • Database
    • Dataframe
    • Dataframe Or Lazyframe
    • Date
    • Debug
    • Default
    • Env
    • Experimental
    • Expression
    • Filesystem
    • Filters
    • Formats
    • Generators
    • Hash
    • History
    • Lazyframe
    • Math
    • Misc
    • Network
    • Path
    • Platform
    • Plugin
    • Prompt
    • Random
    • Removed
    • Shells
    • Strings
    • System
    • Viewers

bits xor for bits

Performs bitwise xor for ints or binary values.

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:

inputoutput
binarybinary
intint
list<binary>list<binary>
list<int>list<int>

Examples

Apply bits xor to two numbers

> 2 | bits xor 2
0

Apply bitwise xor to a list of numbers

> [8 3 2] | bits xor 2
╭───┬────╮
│ 0 │ 10 │
│ 1 │  1 │
│ 2 │  0 │
╰───┴────╯

Apply bitwise xor to binary data

> 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

> 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

> 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