No description
Find a file
2023-08-16 19:33:18 +03:00
.github Add OS-X pipeline 2021-08-16 04:39:12 +03:00
debian Remove dependency on libncurses5 and libreadline5 from debian control 2020-03-18 01:54:18 +02:00
inc Fix divide by zero crash 2023-05-14 23:54:33 +03:00
m4 Update .travis.yml 2019-07-11 20:52:45 +03:00
resources update bitwise movie 2019-07-11 23:09:02 +03:00
src Fix binary prefix parsing 2023-08-16 19:33:18 +03:00
tests Add support for IPv4 parsing and output in command line mode 2021-08-16 04:39:12 +03:00
.editorconfig Add .editorconfig, exclude build output from git 2019-09-06 12:38:23 -04:00
.gitignore Add .editorconfig, exclude build output from git 2019-09-06 12:38:23 -04:00
.travis.yml Update .travis.yml 2020-10-08 10:37:56 +03:00
AUTHORS transform to autotools 2019-04-20 15:33:51 +03:00
bitwise.1 Bump to release v0.50 2023-07-20 23:23:10 +03:00
bootstrap.sh transform to autotools 2019-04-20 15:33:51 +03:00
ChangeLog v0.20 2019-06-17 06:43:02 +03:00
configure.ac Bump to release v0.50 2023-07-20 23:23:10 +03:00
COPYING COPYING file was left as apache, change it to GPLv3 2019-07-12 22:06:54 +03:00
LICENSE change license to GPLv3 2019-04-28 07:21:38 +03:00
Makefile.am Create empty help window 2019-08-09 23:43:24 +03:00
NEWS transform to autotools 2019-04-20 15:33:51 +03:00
README add README as autotools requires it 2019-04-21 11:31:49 +03:00
README.md Update README.md 2023-07-21 23:12:38 +03:00
snapcraft.yaml Bump up to v0.41 2019-12-18 17:40:48 +02:00
ubuntu_release.sh Add script for creating Ubuntu releases 2019-07-19 09:30:36 +03:00

Bitwise

Terminal based bitwise calculator in curses

Snap Status Coverity Scan Build Status Packaging status

Bitwise is multi base interactive calculator supporting dynamic base conversion and bit manipulation. It's a handy tool for low level hackers, kernel developers and device drivers developers.

Some of the features include:

  • Interactive ncurses interface
  • Command line calculator supporting all bitwise operations.
  • Individual bit manipulator.
  • Bitwise operations such as NOT, OR, AND, XOR, and shifts.

Demo

Usage

bitwise can be used both interactively and in command line mode.

Command line calculator mode

In command line mode, bitwise will calculate the given expression and will output the result in all bases including binary representation.

bitwise detects the base by the prefix of the input (0x/0X for hexadecimal, leading 0 for octal, b for binary, and the rest is decimal).

NEW Bitwise now support parsing IPv4 addresses, it will also output the possible IPv4 address in both Network and reversed byte order.

Examples:

Simple base conversion

conversion

C style syntax Calculator

calculator

Interactive mode

bitwise starts in interactive mode if no command line parameters are passed or if the -i | --interactive flag is passed. In this mode, you can input a number and manipulate it and see the other bases change dynamically. It also allows changing individual bits in the binary. You can show the help screen by pressing F1 .

Navigation in interactive mode

To move around use the arrow keys, or use vi key bindings : h j k l . Leave the program by pressing q .

Binary specific movement

You can toggle a bit using the space key. You can jump a byte forward using w and backwards one byte using b .

Bitwise operation in interactive mode

Setting the bit width:

Reducing or extending the bit width interactively is also very easy, just use: ! for 8bit, @ for 16Bit, $ for 32Bit and * for 64Bit. When changing the bit width, the number is masked with the new width, so you might lose precision, use with care.

NOT:

Press ~ to perform the NOT operator.

Reversing Endianness:

Press r to reverse the endianness.

Shifts

Press < and > to perform the left or right shift.

expression calculator in interactive mode

You can enter expression calculator mode by typing : (Just like in vim).

To exit the mode, just press ESC .

In this mode, you can type any expression you like to be evaluated. The result will be printed in the history window and also printed in the binary and various bases on top.

operators and functions
  • All C operators are supported, additionally, you can use the "$" symbol to refer to the last result.
  • Refer to a specific bit by using the function BIT(x).
commands
  • h(elp) - Show the help screen.
  • c(lear) - Clear the history window.
  • w(idth) [8 | 16 | 32 | 64] - Set the required width mask
  • o(utput) [dec(imal) | hex(adecimal) | oct(al) | bin(ary) | all] - Set the default output for results.
  • q(uit) - Exit

Integration with other software

Vim

Installation

Linux

Ubuntu

From 20.04 you can just type

sudo apt-get install bitwise

For earlier versions:

sudo add-apt-repository ppa:ramon-fried/bitwise
sudo apt-get update
sudo apt-get install bitwise

Snap

If your distribution supports Snap just type: sudo snap install bitwise

OpenSuse

zypper install bitwise

Arch

You can use the AUR repository: https://aur.archlinux.org/packages/bitwise/

Void

bitwise is in the default repository, so just type: sudo xbps-install -S bitwise

Fedora Linux

bitwise is available in the official repository

sudo dnf install bitwise

Buildroot / Yocto

Bitwise is available both in Buildroot and in Yocto, please refer to the documentation on how to add those to your target image.

macOS

MacPorts

sudo port install bitwise

Homebrew

brew install bitwise

Windows

NCurses doesn't support Windows. You can use the Windows Subsystem for Linux as a workaround.

Nix

nix-env -i bitwise

Building from source

Prerequisites

  • libreadline
  • libncurses (with forms)
  • libcunit (only needed for testing)

On Ubuntu/Debian system you can just paste:

sudo apt-get install build-essential
sudo apt-get install libncurses5-dev
sudo apt-get install libreadline-dev
sudo apt-get install libcunit1-dev

On Mac systems:

brew install automake
brew install autoconf
brew install readline
export LDFLAGS="-L/usr/local/opt/readline/lib"
export CPPFLAGS="-I/usr/local/opt/readline/include"
tar xfz RELEASE-FILE.TAR.GZ
cd RELEASE-DIR
./configure
make
sudo make install

Running unit tests by typing make check

Contribution

  • Install prerequisites
  • Fork the repo
  • Run ./bootstrap.sh
  • Follow the building from source section.
  • commit and send pull request