DEV Community

Valentin Iljaž
Valentin Iljaž

Posted on

Binary editors in Webacus

Webacus is an innovative platform that offers a comprehensive collection of fast developer tools. It aims to streamline your development process by eliminating the hassles of switching between tabs and constantly copy-pasting data. With Webacus, you can easily chain tools together, creating a unified experience for efficient web development.

One of the standout features of Webacus is its binary editor (or bin editor), often referred to as a hex editor. These specialized tools allow users to view and edit the raw binary data of a file. Unlike traditional text editors that display content as readable text, binary editors provide a more granular view by displaying the underlying hexadecimal values, which represent the actual data stored in the file.

What are binary editors?

At a basic level, a binary editor (also known as hex editor) displays each byte as a two-digit hexadecimal number (00 to FF), paired with its corresponding ASCII character (if one exists). This view allows developers to dive deep into a file's structure, byte by byte. Unlike traditional editors like VS Code or Sublime, binary editors allow you to work with data in its raw form. This can be especially handy when dealing with proprietary formats, encrypted data, or files corrupted in transit.

Webacus also features a specialized binary editor that allows users to view and modify individual bits. The editor displays only 64 bits (8 bytes) and enables precise control by allowing users to toggle each bit individually. This level of detail offers enhanced flexibility and control over the data.

Why do web developers need binary editors?

Understanding complex file formats
While web developers typically work with higher-level programming languages and file formats, there are occasions when a deeper understanding of data structures and file formats is necessary. For instance, if you're working with media files (like images or videos) or low-level protocols, inspecting binary data directly allows you to decode or manipulate metadata, image headers, and even file-specific markers.

Debugging compiled or minified files
If you've ever dealt with a minified or obfuscated JavaScript file, you know how tricky it can be to debug. In some cases, you might receive corrupted or partially compiled files. Opening these files in a binary editor lets you peek under the hood and figure out where things may have gone awry.

Analyzing network packets
If you're working with real-time data streams or WebSockets, you may receive data in binary formats instead of JSON. A binary editor lets you inspect the raw data payload, helping you understand custom binary protocols or decode compressed content from a response.

Reverse engineering and security testing
Understanding the binary representation of files can be critical for reverse engineering tasks. For example, if you're trying to reverse-engineer an API that returns binary data, a binary editor helps in identifying patterns or protocol markers. Additionally, binary editors are often used to inspect malware or third-party scripts for embedded code.

Recovering or repairing corrupt files
In rare cases, data can be corrupted in transit or through storage issues. Binary editors allow developers to manually identify and fix errors or recover lost data by making precise byte-level edits.

Hex editor

When you open a file in a hex editor, it displays the content in three main sections:

Hexadecimal: Shows the file's content as hexadecimal numbers. This is the raw binary data.

ASCII: Displays the ASCII equivalent of the hexadecimal values. This helps you recognize readable text within the binary data.

Offset: This column indicates the byte position in the file, helping you navigate large files more easily.
These three sections combined give you a comprehensive understanding of the data inside a file, allowing you to spot anomalies, inspect headers, or decode hidden data.

Binary editor

Viewing and editing 64 bits or 8 bytes at a time, providing the capability to manipulate individual bits. This feature is particularly useful for tasks that require precise control over data, such as debugging low-level code, analyzing binary protocols, or performing detailed security audits. By enabling bit-level manipulation, the Webacus binary editor empowers developers to achieve a higher degree of accuracy and insight when working with complex binary data.

Use case

Let's determine whether a WebP image is animated. By searching for a programmatic solution, you'll find the following algorithm:

  1. Extract the 20th byte (using a 0-based offset) from the file.
  2. Shift this byte one bit to the right.
  3. Perform a bitwise AND operation with the number 1.
  4. If the result is 1, the image is animated; if it's 0, the image is not animated.
  5. All these steps can be easily performed using online tool Webacus.

First, we start by opening the file: FILE / OPEN

Image description

The result is displayed in the hex editor, with the hexadecimal values on the left and the corresponding ASCII characters (where applicable) on the right.

Next, we extract the 20th byte using the slicing operation: Slice

Image description

We then apply a bitwise right shift: Bit-shift / RIGHT

Image description

The result is displayed in the binary editor, showing individual 64 bits.

Followed by a comparison using a bitwise AND with 1 as the second operand: Bit-ops / AND

Image description

The result is immediately visible as 1, indicating the image is animated.

For additional clarity, we can convert the binary representation into an integer: INTEGER / from-binary

Image description

In conclusion,

using Webacus to determine if a WebP image is animated demonstrates the precision and versatility of the platform's binary editor and other tools. By enabling detailed bit-level operations and providing intuitive visualization, Webacus streamlines complex tasks like inspecting specific bytes and performing bitwise manipulations. This approach not only makes low-level file analysis accessible but also showcases how essential tools can elevate a developer's workflow, turning intricate processes into clear, manageable steps.

Top comments (0)