- Define the string to be converted.
abcde
- Converts to binary numbers based on the ASCII code table
01100001 01100010 01100011 01100100 01100101
- Divide it into 6 bits each
011000 010110 001001 100011 011001 000110 0101
- Add 0 so that the last group is 6 bits
011000 010110 001001 100011 011001 000110 010100
- Convert to characters based on the base64 conversion table
Y W J j Z G U
- Combine them into four letters each
YWJj ZGU
- If the last group is less than 4 characters, add
=
for the number of them
YWJj ZGU=
- Concatenating the groups into a single string completes the base64 string
YWJjZGU=