From external users using xS BLOG
According to the recommendations of the cool, when I was playing a hacker game, one of them met a ciphertext, which looks like a base64 encoding, but garbled code occurs through base64 decoding. Later, we considered Md5 (base64), and then decoded it using base64 and then converted it into a hexadecimal number to get a five-digit number. Obviously, it is not Md5 (base64 ). The combination of base64 and other encodings is also incorrect. Later, I took a closer look at the key points of the pass-through knowledge of the cool city bypass, So that I knew that the ciphertext was base32 encoded. No wonder I could not solve it! Haha! However, google and baidu did not find a decoding tool in a circle, and it seems that they have to do it on their own. At last, I learned the principles of base32 encryption and decryption through research, so I got this article.
I. Introduction to Base32 Data Encoding
Base32 is a data encoding mechanism used to encode binary data into visible strings. the encoding rules are as follows: any given binary data is encoded in five bits) split a group (base64 uses six digits (bit) as a group), and encode each group made from the split to get one visible character. The total number of characters in the Base32 encoding table character set is 25 = 32, which is also the origin of the Base32 name. The following is a standard Base32 encoding table I have found online, as shown in table 1.
Table 1 Standard Base encoding table
Ii. Encoding demonstration
The following uses a specific example to describe the Base32 encoding process. It is encoded with the "bhst" string. The procedure is as follows:
1. After the character "bhst" is taken as an ASCII code, convert it to a binary string and get "1100010,1101000, 1110011,1110100," a total of four bytes, 28 bit binary strings. Note: Because base32 is the encoding method used to transmit 8-bit bytes of code, it is necessary to add 0 to the binary highest bit corresponding to the "bhst" string and change it to 8 bits in each group. A 32-bit binary string.
2. Split the binary string corresponding to the "bhst" string with 5 bits. Obtain the "bhst" binary string of "01100,01001, 10100,00111, 00110,11101, 00000. Note: if there are less than five binary strings in each group, add 0.
3. Calculate the decimal number of each binary string, and then refer to the standard Base32 encoding table to find the corresponding encoding characters and combine them into a secret. Note: When the number of last group digits is less than 4, the character "=" is used for encoding.
See table 2:
Table 2 uses five BITs as a group to split the table into seven bytes.
Standard binary string and standard Base32 Encoding
Iii. instance Decoding
The encoding algorithm is ready. If you want to reverse the decoding, you can. Here, the ciphertext in the game is used as an example. The steps for "I4AG6AA =" are as follows:
1. Find the corresponding decimal encoding value for the encoded characters in the ciphertext (against the standard Base32 encoding table. They are: 8 28 0 6 30 0.
2. Convert the decimal encoded value to binary, and add less than five bits to 0. Obtained: 00000
3. Combine the binary strings in each group and split them with 8 bits. Obtained: 01000111,00000000, 01101111,00000000, 00000000
4. Restore each binary string to get the plain text ASCII code 71 0 111 0 0, and restore it to the character Go.
As shown in table 3:
Iv. Summary
Through the study of Base32 encryption and decryption algorithms, this is the last step. This article is based on my personal understanding. If you have any mistakes, please point them out.