Tools / Bit Shift Calculator
Bit Shift Calculator
Quickly apply left or right bit shifts to numbers from binary, octal, decimal, or hexadecimal inputs and view the results in every base simultaneously.
Shift Direction
Converted values
Decimal
480
Binary
111100000
Hexadecimal
1e0
Octal
740
How it works
A left shift by n bits multiplies by 2n; a right shift divides (integer). In binary, this is just moving the bit pattern left or right and filling with zeros.
Challenges solved with this tool: picoCTF 2024 - Binhexa.
There are two flavors of right shift. A logical right shift always fills vacated bits on the left with zeros, treating the value as unsigned. An arithmetic right shift replicates the sign bit, preserving the sign of a two's-complement integer. In most high-level languages, >> on a signed type is arithmetic, while on an unsigned type it is logical. CTF reverse engineering problems often involve tracking which kind of shift the original code used.
Left shifts and right shifts are frequently used in custom encoding and obfuscation schemes. A value may be constructed by shifting sub-values into specific bit positions and ORing them together. For example, (a << 8) | b packs two bytes into a 16-bit word. Recognizing this pattern in decompiled code is a key reverse engineering skill.
In CTF challenges involving custom hash functions or checksums, shift operations are combined with XOR and addition to mix bits. If you see a sequence of shifts by constants like 7, 13, or 17, you are likely looking at a bit-rotation or mixing round from a hash-like construction. Use this calculator to verify what each individual shift step produces.
Challenges where it helps
Guides that use this tool
- Integer Overflow and Signedness Bugs for CTFWrap-around, signedness confusion, and truncation explained with two's complement, then used to buy flags, defeat length checks, and mint unlimited tokens.
- Insecure Randomness for CTF: Predicting PRNGs and the Mersenne TwisterPredict Python's random, crack the Mersenne Twister with randcrack from 624 outputs, brute a time() seed, and recover an LCG. Working code for CTF guessing games.
- z3 for CTF: Constraint Solving from Keychecks to CryptoA z3 solver tutorial for CTF: the four-move script skeleton, the BitVec-vs-Int type trap that silently breaks solutions, and when z3 beats angr or brute force.
- Stream Ciphers in CTFs: LFSR, Vigenere, and Keystream ReuseStream ciphers in CTF: three weaknesses break almost every one, short keys, reused keystreams, and linear feedback, with Berlekamp-Massey and Kasiski in Python.
Tools that pair with this one
- Binary CalculatorPerform binary arithmetic (add, subtract, multiply, divide) with copyable outputs in every base.
- Number Base ConverterConvert numbers between binary, octal, decimal, and hexadecimal instantly. Enter any value and see all four bases update in real time.
- Endianness ConverterConvert between big-endian and little-endian byte order with visual byte layout. Supports 16-bit, 32-bit, and 64-bit words.
- XOR CipherXOR-decrypt hex or text ciphertext with a known key, or brute-force the single-byte key automatically.
Or browse all 40 CTF tools.