跳到主要内容
uencoder

如何Convert Hex 到 Binary

转换 hexadecimal strings to binary representation and understand the relationship between the two.

问题

你有 hex 字符串 (e.g., 从 hash digest) 和 need 其二进制 (0s 和 1s) representation 为分析或 低-级别工作.

前置条件

  • Understanding 的十六进制 (进制-16)
  • Understanding 的二进制 (进制-2)

步骤

  1. 1. Split the hex into nibbles

    Each hex digit (nibble) corresponds to exactly 4 binary bits. Split the hex string into individual characters so you can map each one independently.

    输入
    1A
    输出
    nibbles: 1, A
  2. 2. Map each nibble to 4 bits

    Convert each hex digit to its 4-bit binary equivalent: 1 → 0001, A → 1010. Concatenate the results. Do not drop leading zeros in any nibble.

    输入
    1A
    输出
    00011010
  3. 3. Verify the result

    Group the binary output into bytes (8 bits) and confirm each byte matches the original hex pair. 1A in hex equals 26 in decimal, which equals 00011010 in binary.

    输入
    00011010
    输出
    decimal: 26 ✓

预期结果

二进制字符串 where 每个 hex 数字 expanded 到 exactly 4 bits, preserving leading zeros.

常见错误

Dropping leading zeros in the first nibble
Always pad each nibble to exactly 4 bits. The hex value 0F must become 00001111, not 1111.
Including the 0x prefix in the conversion
Strip the 0x prefix before converting. It is a notation marker, not part of the value.

排障指引

  • If the binary length is not 4× the hex length, you dropped a leading zero.
  • Use a base converter tool to cross-check the result.

安全限制

  • This is a pure format conversion with no security implications.

相关工具

相关词条

参考链接