八位字节字符串:它是什么?
我开始研究我即将接手的项目的一些网络编程概念,并且我不断遇到八位字节字符串的概念。 任何人都可以提供一些关于这是什么以及它与网络编程有何关系的反馈吗?
I am starting to look into some network programming concepts for a project I am about to take over, and I keep running into this concept of an octet string. Can anyone out there provide some feedback into what this is, and how it relates to network programming?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
八位字节串:
以有限的8位模式表示信息。 在将数据从电子设备的一个点传输到设备的另一个点或任何其他设备的过程中,需要将它们转换成最小尺寸的包。 因此,它被用来将主要数据划分为小的并且系统可以理解的。 例如:
因此,二进制 101001111000 形式的整数 2680 将被转换为 7 位格式,如下所示:
剩余整数--------------------编码字节
101001111000------------------------
10100---------------------------- -----------------01111000
0------------------------ -----------11111000
&00010100
分别表示为十进制的(120) (20)。
然后将 120 除以 16 并将结果存储为 = 7 & 提醒=8
再次将 20 除以 16 进行存储,结果 = 1 & 提醒= 4
新的数字形式是 0X78 + 0X14
这里 78 & 14 是八位字节串。
将它们编码到正常阶段: ((16*7)+8)*128^0+((16*1)+4)*128^1 = 2680
我认为这是更好的解释,但我仍在搜索更多关于它。 请帮助我了解字母表。 我认为这取决于它的 ASCII 值。
octet string:
it is representation of information in the limited 8 bit mode. During transferring the data from a point of electronics device to another point of device or any other device it need to convert them into package of minimum size. So it is used to divide the main data in small and system understandable. eg:
So the integer 2680, in binary 101001111000 will be converted into that 7-bit format as follows:
Remaining integer-------------------encoded bytes
101001111000------------------------
10100-------------------------------01111000
0-----------------------------------11111000
&00010100
Which is represented as (120) (20) separately as decimal.
then the divide 120 by 16 an store as result = 7 & reminder = 8
again divide 20 by 16 an store as result = 1 & reminder = 4
the new form of number is 0X78 + 0X14
here 78 & 14 are Octet String.
to encode them to Normal stage: ((16*7)+8)*128^0+((16*1)+4)*128^1 = 2680
I think it is the better explanation, but still i am searching more about it. Please help me to get about the alphabets. I think it depends on its ASCII value.
计算机中的一组 8 位称为一个八位组。 对于大多数实际用途来说,一个字节是相同的,但在所有计算机体系结构上并不等于 8 位。
更多信息可以在这里找到.. 链接
A group of 8 bits in a computer is called an octet. A byte is the same for most practical purposes, but does not equal 8 bits on all computer architectures.
More can be found here .. Link
Octet
是计算机中表示 8 位数据的术语。字节
是指在计算机中对字符串字符进行编码所需的位数的术语。Octet
始终是 8 位。 但字节大小因硬件而异。 大多数系统都支持 ASCII 方式的字符串编码。 在这些机器中,字节
大小为八位。 一些支持 unicode 的硬件使用 16 位作为一个字节
。Octet
is the term to mention 8 bit data in computer.Byte
is the term to mention number of bit required to encode a string character in computer.Octet
is always 8 bits. ButByte
size varies depends on the hardware. Most of the system is supporting ASCII way of encoding strings. In those machinesByte
size is eight bits. Some of the unicode supporting hardware is using 16bits as oneByte
.可变长度的八位位组序列(如抽象语法表示法一 (ASN.1) 中所示)称为八位位组字符串。
A variable-length sequence of octets, as in Abstract Syntax Notation One (ASN.1), is referred to as an octet string.
使用术语“八位字节”是为了避免歧义,因为一些旧计算机的每字节位数不同。
与名称所暗示的不同,此数据类型
不限于字符串值
,而是可以存储任何基于字节的数据类型(包括二进制数据)。下面是一个基于 Java 的类,它尝试将 Decimal 转换为其 OctetString。
}
The term "octet" is used to avoid ambiguity, because some old computers had different numbers of bits per byte.
Unlike what the name suggests, this data type is
not limited to string values
but can store any byte based data type (including binary data).Below is a Java based class that tries to convert a Decimal to its OctetString.
}
这是将十进制转换为 OctetString 的 python3 代码:
好简单
Here is a python3 Code for the conversion of decimal to OctetString:
Very easy
八位位组 = 字节。
八位字节串 = 字节序列。
另请参阅维基百科。
Octet = byte.
Octet string = sequence of bytes.
Also, see Wikipedia.
“Octet”是“8 位字节”的标准术语。 与“字节”相比,它应该是一个不太模糊的术语,因为某些平台具有不同宽度的字节(不确定是否还有剩余,但它们曾经存在)。
"Octet" is standardese for "8-bit byte". It's supposed to be a less ambiguous term compared to just "byte", because some platforms have bytes of different width (not sure if there are any are still remaining, but they used to exist).
假设二进制 00000000 到 11111111 的表示为十六进制的 0x00 到 0xFF。 那么八位字节字符串就是 00 到 FF。
将几个八位位组组合成一个字符串就像 0x00 0x01 0x02 ... 或简单地 000102.. 作为八位位组字符串。
二进制文件可以编码为八位字节字符串,并以包含 0-F 字母表的 ASCII 字符串形式从 webbclient 发送到服务器,例如 a8b9457fc6e3e410589f 或其大写字母。 有使用 BASE-64 编码的 JavaScript 用于在字符串中存储图片。 字母表越大,在这种情况下(我认为)AZ,az,0-9,需要传输的数据越少。 每个八位位组有 256 个不同的可能值,并且要存储在 62 个字母的字母表中,显然需要使用多个字母/八位位组。 理论数字可能与 log62(256) 成正比。
结论是,改进的可读性比二进制版本占用更多的空间,在八位字节流示例中,它的长度是两倍,因为每个 ascii 字符是八位,而 2 个字符(16 位)表示一个八位字节。 相当低效。
Suppose a representation of binary 00000000 to 11111111 as 0x00 to 0xFF in hexadecimal. Then the octetString is simply 00 to FF.
Combining several octets to a string is then like 0x00 0x01 0x02 ... or simply 000102.. as an octetstring.
Binary files can be encoded into octetstrings and sent from a webbclient to a server in the form of an ASCII-string containing the 0-F alphabet, like a8b9457fc6e3e410589f or it's capitals. There are javascript using BASE-64 encoding used to store pictures in Strings. The larger alphabet, in this case(I think ) A-Z,a-z,0-9, the less data needs to be transferred. every octet has 256 different possible values, and are to be stored in an alphabet of 62 letters, clearly one needs to use more than one letter / octet. Possibly the theoretical number is proportional to log62(256).
The conclusion is that improved readability takes more space than it's binary version, in the octetstream example it's twice as long since each ascii char is eight bits and 2 chars (16 bits) represent an octet which is eight bits. Quite inefficient.