Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Introduction of base coding Family based on Cryptography

2025-03-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Network Security >

Share

Shulou(Shulou.com)06/01 Report--

Base64. As the name implies, it is a way to represent binary data based on 64 printable characters. (it is not an encryption algorithm). For 64 printed characters, we need 6 binary bits to fully represent the word. So how do we use eight binary bits to represent printable characters that can be fully represented by only six binary bits? Since the sixth power of 2 equals 64, we can divide every six bits into a unit that corresponds to a printable character. Three bytes have 24 bits, corresponding to 4 Base64 units, that is, 3 bytes need to be represented by 4 printable characters (a character in a normal ASCII code has 8 bits, but only 6 bits out of these 64 characters). It can be used as the transmission code of e-mail. Printable characters in Base64 include the letters Amurz, Amurz, and the numbers 0-9, so there are a total of 62 characters, in addition to two printable symbols that vary from system to system.

Base64 index table: (original table)

Example of coding process:

Coding

The top three bytes are the original text, and the next four bytes are converted Base64 encodings, with the first two bits 0.

After conversion, we get the string we want (that is, the final Base64 encoding) by converting the binary to printable characters.

We can see that after base64 encoding, the string is theoretically longer than before, that is, the original 4ax 3. (except for the following two cases).

If the number of bytes to be encoded is not divisible by 3, resulting in an extra 1 or 2 bytes, you can use the following method: use the 0 byte value at the end to make it divisible by 3, and then encode base64. Add one or two'= 'signs to the encoded base64 text to represent the number of bytes to be filled. In other words, when the last octet (one byte) is left, the last 6-bit base64 byte block has four bits of zero value, followed by two equal signs; if the last two octets (2 byte) are left, the last 6-bit base byte block has two bits of zero value, followed by an equal sign.

There is usually an = sign after base64 coding, and the longer ciphertext length is basically base64 coding. (base64 encoding pair) (the equal sign is the result of modification of 64 printable characters depending on usage.)

Application of base64

Https://zh.wikipedia.org/zh/Base64

In the base family, there are base64,base32,base16 and the legendary base8.

In the http://xiaoqin00.blog.51cto.com/10468367/1713961 coding of base64, we say that base64 coding uses 64 (2 to 6) ASCII characters to represent 256 (2 to 8) ASCII characters, that is, the three-bit binary array is encoded into four-bit ASCII character display, which is 1x3 longer than the original.

Similarly, base32 uses 32 (2 to the fifth power) specific ASCII codes to represent 256 ASCII codes. Therefore, after 5 ASCII characters are encoded by base32, they will become 8 characters (common divisor is 40), and the length will increase by 3 pm 5. 5.

Base16 uses 16 (2 to the fourth power) specific ASCII codes to represent 256 ASCII characters. After 1 ASCII character is encoded by base16, it becomes 2 characters, doubling the length.

In the base family, base64 is written first and base32 is not written in 189s.

The base64 contains uppercase letters (Amurz), lowercase letters (amurz), the numbers 0muri 9 and + /

There are only capital letters (Amurz) and the number 234567 in base32

Base32 index table:

There are only the numbers 0-9 and the uppercase letter ABCDEF in base16.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Network Security

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report