A collection of utilities for performing bitwise operations on files.
Compile all binaries using:
go build -o build ./...This will place the compiled executables in the build directory.
binop applies a bitwise operation across multiple input byte streams.
For each byte position, the selected bitwise operator is applied to the corresponding byte from every input stream. The first output byte is computed from the first byte of each input, the second output byte from the second byte of each input, and so on.
If an input file is shorter than the others, it is wrapped and read again from the beginning.
The output stops once all file inputs have been fully consumed. Note that as a special case, standard input (-) cannot be wrapped.
Inputs are provided as command-line arguments and can be:
| Format | Meaning |
|---|---|
filename |
Read bytes from a file |
./filename |
Explicit file path (useful if the name conflicts with a special format) |
- |
Standard input |
0x<hex> |
Static byte string encoded as hexadecimal |
binop is implemented as a single binary.
The operation it performs depends on the name used to invoke the executable.
Create symbolic links for the desired operators:
ln -s binop <operator>Supported operators:
| Command | Operation |
|---|---|
and |
Bitwise AND |
nand |
Bitwise NAND (NOT AND) |
or |
Bitwise OR |
xor |
Bitwise XOR (exclusive OR) |
Example usage:
./xor file1.bin file2.bin 0xFF > result.binThis command:
- Reads bytes from
file1.bin - Reads bytes from
file2.bin - Uses the static byte
0xFF - Applies bitwise XOR to each byte position
The result is written to result.bin.