BitCraft-S is a powerful bit manipulation calculator with structure support. It provides visual bit editing, mathematical operations, and advanced structure field management - perfect for hardware engineers, protocol developers, and low-level programmers.
🚀 Quick Features
Visual Bit Editor
Click any bit to toggle 0/1
Structure Support
Define and edit bitfield structures
Expression Evaluator
Calculate with variables and operators
Smart Display Formats
Auto IPv4, MAC, IPv6 for fields
Arbitrary Bit Width
1-1024 bits, not limited to 4x
Dual Bit Ranges
Shows global and field-relative ranges
📝 Basic Operations
CORE
Variable Assignment
Create and assign values to variables. Supports HEX, DEC, and BIN formats.
Examples:
>>> A = 100
A updated
>>> B = 0x32
B updated
>>> C = 0b11010
C updated
// Query variable
>>> A
A = 0x00000064 (100)
NEW
Arbitrary Bit Width
Create variables with any bit width (1-1024 bits), not limited to 4-bit nibbles. Use quick buttons for common widths or the "Set" button for custom values.
Command Line Syntax: Variable:bits = value
>>> A:5 = 0x1F
A (5 bits) = 0x1F
>>> B:13 = 0x1ABC
B (13 bits) = 0x1ABC
// Values auto-truncate to bit width
>>> C:7 = 0xFF
C (7 bits) = 0x7F // 0xFF & 0x7F = 0x7F
Quick Width Buttons (in UI):
// Click these buttons to instantly change bit width:
[128] [96] [64] [48] [32] [16] [Set]
// Common use cases:
[128] → IPv6 addresses, UUIDs
[96] → Some encryption keys
[64] → long, double, timestamps
[48] → MAC addresses
[32] → int, IPv4 addresses
[16] → short, port numbers
// Click [Set] button for custom bit width (1-1024)
[Set] → Modal opens → Enter: 13 → Creates 13-bit variable
NEW
Expression Evaluation
Perform calculations using variables, numbers, and operators. Supports arithmetic, bitwise, and shift operations.
Arithmetic Operations:
>>> A = 100
>>> B = 0x32
>>> C = A + B + 0x1
C = 0x00000097 (151)
>>> D = A * 2 - B
D = 0x00000096 (150)
Bitwise Operations:
>>> E = A & 0xFF
E = 0x00000064 (100)
>>> F = A | B
F = 0x00000072 (114)
>>> G = A ^ B
G = 0x00000052 (82)
Shift Operations:
>>> H = 0x10 << 2
H = 0x00000040 (64)
>>> I = 0xFF >> 4
I = 0x0000000F (15)
>>> J = (A << 1) + B
J = 0x000000FA (250)
CORE
Bit Range Operations
Extract or modify specific bit ranges within a variable.
Syntax: Variable[high:low]
>>> A = 0x12345678
// Extract bits [23:16]
>>> A[23:16]
A[23:16] = 0x34 (52)
// Modify bits [15:8]
>>> A[15:8] = 0xAB
A[15:8] updated
// A is now 0x1234AB78
🏗️ Structure Support
ADVANCED
Structure Definition
Define bitfield structures with named fields. Supports two syntax styles and two field separators (, or ;).
Syntax 1: Width Style
>>> S{A:8, B:16, C:8} = 0x12345678
S created.
Syntax 2: Range Style
>>> T{A[31:24], B[23:8], C[7:0]} = 0x12345678
T created.
Alternative: Semicolon Separator
>>> U{A:8; B:16; C:8} = 0x12345678
U created.
>>> V{A[31:24]; B[23:8]; C[7:0]} = 0x12345678
V created.
// Both , and ; work as field separators
Complex Structure Example:
>>> IP{VER:4, HDL:4, DSCP:6, ECN:2, TLEN:16, ID:16, FLAG:3, FRAG:13, TTL:8, PROTO:8, CKS:16, SIP:32, DIP:32} = 0x451C00140000000000007F000001E0000001
IP created.
// Total: 160 bits (IPv4 header)
ADVANCED
Field Access & Modification
Read and write individual structure fields using dot notation.
Field Query:
>>> IP.SIP
IP[31:0].SIP[31:0] = 0x7F000001 (2130706433) [127.0.0.1]
>>> IP.VER
IP[3:0].VER[3:0] = 0x4 (4)
// Format: Structure[global_range].Field[field_range] = HEX (DEC) [special]
Field Assignment:
>>> IP.SIP = 0xC0A80001
IP[31:0].SIP[31:0] = 0xC0A80001 (was 0x7F000001)
>>> IP.TTL = 64
IP[7:0].TTL[7:0] = 0x40 (was 0x0)
Field Expressions:
>>> IP.SIP = 0x7F000001
>>> A = IP.SIP + 1
A = 0x7F000002
>>> B = IP.SIP & 0xFF
B = 0x00000001
NEW
Smart Field Display with Special Formats
Fields automatically display in special formats based on their bit width:
- 32-bit → IPv4 address
- 48-bit → MAC address
- 128-bit → IPv6 address
IPv4 Address (32-bit):
>>> IP{..., SIP:32, DIP:32} = ...
>>> IP.SIP
IP[31:0].SIP[31:0] = 0xC0A80001 (3232235521) [192.168.0.1]
>>> IP.DIP
IP[31:0].DIP[31:0] = 0x08080808 (134744072) [8.8.8.8]
MAC Address (48-bit):
>>> ETH{DST:48, SRC:48, TYPE:16} = ...
>>> ETH.SRC
ETH[47:0].SRC[47:0] = 0x001122334455 (18838586676309) [00:11:22:33:44:55]
>>> ETH.DST
ETH[47:0].DST[47:0] = 0xFFFFFFFFFFFF (281474976710655) [FF:FF:FF:FF:FF:FF]
IPv6 Address (128-bit):
>>> IPv6{ADDR:128} = 0x20010DB885A3000000008A2E03707334
>>> IPv6.ADDR
IPv6[127:0].ADDR[127:0] = 0x20010DB8... (...) [2001:db8:85a3:0:0:8a2e:370:7334]
Click Field Name to Query:
// In the UI, click on any field name in the visual display
[Click "SIP"] → Automatically executes: IP.SIP
IP[31:0].SIP[31:0] = 0x7F000001 (2130706433) [127.0.0.1]
NEW
Field HEX Input with Expressions
Type expressions directly in the field's HEX input box. The result is automatically truncated to the field width.
In the UI:
// Field "SIP" originally: 0xA1
// Type in HEX input box:
0xA1 << 2 // Result: 0x284 (auto-truncated to field width)
0xA1 + 0x10 // Result: 0xB1
0xFF >> 4 // Result: 0x0F
IP.DIP & 0xFF // Can reference other fields!
(0x12 << 4) | 0x34 // Complex expressions work
Auto-Truncation:
// Field width: 8 bits (mask = 0xFF)
0x1234 // Stored as: 0x34
// Field width: 4 bits (mask = 0xF)
0xFF // Stored as: 0xF
// Field width: 16 bits
0x1234 << 5 // Result: 0x4680 (0x24680 truncated)
ADVANCED
Visual Field Editing
Each structure field displays:
- Field name with per-field MSB/LSB (relative to field, not global)
- Editable HEX value (supports expressions)
- Clickable bit buttons aligned to global bits above
Field Display Structure:
┌─────────────────┐
│ 4 FieldName 0 │ ← Header (per-field MSB/LSB)
├─────────────────┤
│ 0x12 │ ← HEX Input (supports expressions)
├─────────────────┤
│ 1 0 0 1 0 │ ← Bit Buttons (click to toggle)
└─────────────────┘
// Example: 5-bit field
// MSB = 4 (not global bit 28)
// LSB = 0 (always 0 for per-field)
Perfect Alignment:
// Global bits row:
│0│0│0│1│0│0│1│0│0│0│1│1│ ...
// Field A bits (aligned!):
│0│0│1│
// Field B bits (aligned!):
│1│0│0│1│0│
// Each field bit aligns perfectly with global bits above
⚡ Advanced Features
CORE
Visual Bit Editor
Click any bit in the visual display to toggle between 0 and 1. Works for both global bits and per-field bits.
Usage:
// Create a variable
>>> A = 0x0
// Click on bit 0 → A becomes 0x1
// Click on bit 4 → A becomes 0x11
// Click on bit 0 again → A becomes 0x10
// For structures, click field bits to modify that specific field
CORE
Operations & Apply
Apply bitwise and arithmetic operations to variables using the operation dropdown and "Go" button.
Available Operations:
Shift: << (left) >> (right)
Arithmetic: + - * / %
Bitwise: & | ^ ~ (NOT)
Example:
// 1. Create variable A = 0x10
// 2. Select operation: <<
// 3. Enter argument: 2
// 4. Click "Go"
// Result: A = 0x40
CORE
Multiple Number Formats
Input and display values in HEX, DEC, or BIN formats.
Input Formats:
>>> A = 0x1A // Hexadecimal (prefix: 0x)
>>> B = 26 // Decimal (no prefix)
>>> C = 0b11010 // Binary (prefix: 0b)
// All three represent the same value: 26
Display:
// Each variable shows:
- Header: HEX value (clickable to copy)
- Body: DEC value (clickable to copy)
- Grid: HEX nibbles and binary bits
CORE
Big Number Support
Work with numbers up to 1024 bits (256 nibbles). Perfect for cryptographic keys, IPv6 addresses, and large data structures.
Examples:
// IPv6 address (128 bits)
>>> IPv6 = 0x20010DB885A3000000008A2E03707334
// 256-bit number
>>> BigNum:256 = 0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
// Set custom width using the "Set" button
// Supports 1-256 nibbles (4-1024 bits)
CORE
Persistent Storage
All variables, structures, and their states are automatically saved to browser localStorage. Your work is preserved across sessions. Scroll positions are maintained during bit operations for smooth editing experience.
Features:
✓ Auto-save on every change
✓ Restores on page reload
✓ Remembers scroll positions (both horizontal and vertical)
✓ Maintains view position during bit toggle operations
✓ Saves operation states
✓ Click "RESET" button to clear all data
CORE
Smooth Editing Experience
BitCraft-S maintains your view position during all operations, ensuring a smooth editing experience even with multiple large objects.
View Position Maintenance:
// Working with multiple objects:
>>> A = 0x1234
>>> B = 0x5678
>>> C = 0x9ABC
>>> D = 0xDEF0
// Scroll down to object D
// Click any bit in D
// ✓ View stays on D (doesn't jump back to top)
// Scroll horizontally to view MSB bits
// Toggle any bit
// ✓ Horizontal position maintained
Benefits:
✓ No view jumping when editing bits
✓ Both vertical and horizontal scroll maintained
✓ Smooth multi-object workflow
✓ Focus stays where you're working
✓ Efficient for large structures (160+ bits)
💡 Tips & Tricks
Keyboard Shortcuts
Enter Execute command or apply field edit
Esc Clear command input
Click Toggle bits, copy values
Quick Copy
Click on any HEX or DEC value to copy it to clipboard.
Right-Aligned Display
The bit grid is right-aligned by default, showing the LSB (Least Significant Bit) on the right side. For wide structures, scroll left to see MSB bits.
Common Use Cases
Network Protocol Headers:
>>> TCP{SRC:16, DST:16, SEQ:32, ACK:32, ...} = 0x...
Hardware Registers:
>>> STATUS{READY:1, ERROR:1, BUSY:1, RESERVED:29} = 0x...
Bit Masking:
>>> MASK = 0xFF00
>>> VALUE = DATA & MASK
Flags Management:
>>> FLAGS{READ:1, WRITE:1, EXEC:1, RESERVED:29} = 0x5
>>> FLAGS.WRITE = 1 // Set write flag