词条 | Binary-to-text encoding | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
释义 |
}}{{anchor|ASCII armor}} A binary-to-text encoding is encoding of data in plain text. More precisely, it is an encoding of binary data in a sequence of printable characters. These encodings are necessary for transmission of data when the channel does not allow binary data (such as email or NNTP) or is not 8-bit clean. PGP documentation ({{IETF RFC|4880}}) uses the term ASCII armor for binary-to-text encoding when referring to Base64. DescriptionThe ASCII text-encoding standard uses 128 unique values (0–127) to represent the alphabetic, numeric, and punctuation characters commonly used in English, plus a selection of control codes which do not represent printable characters. For example, the capital letter A is ASCII character 65, the numeral 2 is ASCII 50, the character } is ASCII 125, and the metacharacter carriage return is ASCII 13. Systems based on ASCII use seven bits to represent these values digitally. In contrast, most computers store data in memory organized in eight-bit bytes. Files that contain machine-executable code and non-textual data typically contain all 256 possible eight-bit byte values. Many computer programs came to rely on this distinction between seven-bit text and eight-bit binary data, and would not function properly if non-ASCII characters appeared in data that was expected to include only ASCII text. For example, if the value of the eighth bit is not preserved, the program might interpret a byte value above 127 as a flag telling it to perform some function. It is often desirable, however, to be able to send non-textual data through text-based systems, such as when one might attach an image file to an e-mail message. To accomplish this, the data is encoded in some way, such that eight-bit data is encoded into seven-bit ASCII characters (generally using only alphanumeric and punctuation characters—the ASCII printable characters). Upon safe arrival at its destination, it is then decoded back to its eight-bit form. This process is referred to as binary to text encoding. Many programs perform this conversion to allow for data-transport, such as PGP and GNU Privacy Guard (GPG). Encoding plain textBinary-to-text encoding methods are also used as a mechanism for encoding plain text. For example:
By using a binary-to-text encoding on messages that are already plain text, then decoding on the other end, one can make such systems appear to be completely transparent. This is sometimes referred to as 'ASCII armoring'. For example, the ViewState component of ASP.NET uses base64 encoding to safely transmit text via HTTP POST, in order to avoid delimiter collision. {{See also|Delimiter#ASCII armor|Return-to-libc attack#Protection from return-to-libc attacks}}Encoding standardsThe table below compares the most used forms of binary-to-text encodings. The efficiency listed is the ratio between number of bits in the input and the number of bits in the encoded output.
The 95 isprint codes 32 to 126 are known as the ASCII printable characters. Some older and today uncommon formats include BOO, BTOA, and USR encoding. Most of these encodings generate text containing only a subset of all ASCII printable characters: for example, the base64 encoding generates text that only contains upper case and lower case letters, (A–Z, a–z), numerals (0–9), and the "+", "/", and "=" symbols. Some of these encoding (quoted-printable and percent encoding) are based on a set of allowed characters and a single escape character. The allowed characters are left unchanged, while all other characters are converted into a string starting with the escape character. This kind of conversion allows the resulting text to be almost readable, in that letters and digits are part of the allowed characters, and are therefore left as they are in the encoded text. These encodings produce the shortest plain ASCII output for input that is mostly printable ASCII. Some other encodings (base64, uuencoding) are based on mapping all possible sequences of six bits into different printable characters. Since there are more than 26 = 64 printable characters, this is possible. A given sequence of bytes is translated by viewing it as stream of bits, breaking this stream in chunks of six bits and generating the sequence of corresponding characters. The different encodings differ in the mapping between sequences of bits and characters and in how the resulting text is formatted. Some encodings (the original version of BinHex and the recommended encoding for CipherSaber) use four bits instead of six, mapping all possible sequences of 4 bits onto the 16 standard hexadecimal digits. Using 4 bits per encoded character leads to a 50% longer output than base64, but simplifies encoding and decoding—expanding each byte in the source independently to two encoded bytes is simpler than base64's expanding 3 source bytes to 4 encoded bytes. Out of PETSCII's first 192 codes, 164 have visible representations when quoted: 5 (white), 17–20 and 28–31 (colors and cursor controls), 32–90 (ascii equivalent), 91–127 (graphics), 129 (orange), 133–140 (function keys), 144–159 (colors and cursor controls), and 160–192 (graphics).[6] This theoretically permits encodings, such as base128, between PETSCII-speaking machines. Notes{{Notelist}}References1. ^http://www.columbia.edu/kermit/ftp/boo/ckboo.txt 2. ^{{cite mailing list |url = http://www.columbia.edu/kermit/ftp/e/mail.88a |title = Announcing MS-DOS Kermit 2.30 |publisher = Kermit Project, Columbia University |mailinglist = Info-Kermit Digest |date = 1988-01-11 |accessdate = 3 March 2016 |author1 = Doupnik, Joe |author2 = da Cruz, Frank }} 3. ^{{cite mailing list |url = http://www.columbia.edu/kermit/ftp/e/mail.86a |title = Re: Printable Encodings for Binary Files |publisher = Kermit Project, Columbia University |mailinglist = Info-Kermit Digest |date = 1986-03-20 |accessdate = 1 March 2016 |author = da Cruz, Frank }} 4. ^{{IETF RFC|1751}}"A Convention for Human-Readable 128-bit Keys" 5. ^1 {{IETF RFC|1760}} "The S/KEY One-Time Password System". 6. ^http://sta.c64.org/cbm64pet.html et al 3 : Binary-to-text encoding formats|Computer file formats|Character encoding |
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。