bin2hex
在字节级别将二进制数据转换为十六进制字符串,或将十六进制转换回二进制——类似 PHP 的 bin2hex() 和 hex2bin()。
The `bin2hex` operation — converting raw binary bytes to their hexadecimal string representation — is a fundamental operation in systems programming, cryptography, and network protocol work. It is how you print a byte array in a debugger, how you display a cryptographic hash, and how you serialise binary data for storage in a text field or transmission in a JSON payload.
This tool converts binary data (entered as raw text, where each character is treated as its byte value) to a hex string, and reverses the process to convert a hex string back to binary. It operates at the byte level, making it the right tool for working with file signatures, hash values, binary protocol fields, and any situation where you need to inspect or construct the exact byte-level content of a value.
如何在线使用 bin2hex
- 1
粘贴十六进制或二进制输入
粘贴十六进制字符串以查看二进制字节表示,或粘贴十六进制编码的字节以格式化十六进制转储形式查看。
- 2
检查字节级数据
每个字节显示为两个十六进制数字。如果输入的十六进制字符数为奇数,工具会自动警告并在左侧补零。
- 3
复制结果
复制十六进制或二进制输出,用于代码、协议调试或 CTF 挑战。
How bin2hex Conversion Works
At the byte level, bin2hex is straightforward: each input byte is formatted as exactly two hex digits, zero-padded on the left if necessary, and the results are concatenated. The byte value 0 becomes `00`, 10 becomes `0a`, and 255 becomes `ff`. The output length is always exactly twice the input length in bytes — a predictable property that makes hex strings easy to work with programmatically: you can always extract byte N from a hex string by taking characters at positions `2N` and `2N+1`.
The reverse operation (hex-to-binary) splits the hex string into two-character groups, parses each as a base-16 integer, and emits the corresponding byte. Error handling is important: an odd-length hex string, a character outside `0-9a-fA-F`, or a value above `0xFF` in a group all indicate malformed input that must be rejected rather than silently truncated.
为什么使用 FileCrank bin2hex?
- ✓ 字节级十六进制转换,匹配 PHP bin2hex() / hex2bin() 的行为。
- ✓ 自动警告并纠正奇数长度的十六进制输入。
- ✓ 适用于协议载荷、加密输出和 CTF 挑战。
- ✓ 完全在浏览器中运行——不向任何服务器发送数据。
功能与规格
常见问题
bin2hex 和十六进制转换器有什么区别?
十六进制转换器将人类可读的文本字符串与十六进制相互转换。bin2hex 在原始字节数据级别运行——二进制协议载荷、文件字节、加密输出——这些数据可能无法形成有效文本。使用 bin2hex 进行字节级检查。
PHP 的 bin2hex() 函数有什么作用,我可以在这里复现吗?
PHP 的 bin2hex() 接受二进制字符串并返回十六进制字符串,其中每个字节表示为两个十六进制数字。此工具复现该行为。字符串 A(ASCII 65 = 0x41)编码为 41。
为什么输入奇数个十六进制字符会产生警告?
十六进制编码始终表示完整字节——每个字节恰好是两个十六进制字符。奇数意味着第一个字节不完整。工具在左侧补 0 并显示警告,说明输入已被调整。
此工具对 CTF 挑战有用吗?
有用。许多 CTF 挑战涉及十六进制转储、二进制载荷和编码层。此工具可在浏览器中快速进行字节级十六进制转换,无需本地工具。
bin2hex vs. xxd vs. Python binascii
Python's `binascii.hexlify()` and `bytes.hex()` are the idiomatic in-code solution but require a script or REPL. The `xxd` command produces a formatted hex dump with address offsets and ASCII representation in columns — excellent for file inspection but verbose for extracting a single hex value. A browser-based bin2hex tool is the fastest option when you have a short binary string or hash value and need its hex form (or vice versa) right now, without writing code or opening a terminal.
相关工具
FileCrank bin2hex 在字节级别在二进制数据和十六进制字符串之间转换,复现 PHP 的 bin2hex() 和 hex2bin() 函数,完全在浏览器中运行。
Advertisement