search
HomeCommon ProblemWhat is the principle of base64 encoding?

The base64 encoding principle is to disassemble an 8-bit subsection sequence into 6-bit fragments, and assign a character to each 6-bit fragment. These 64 characters are lowercase letters [a-z] and uppercase letters [A-Z] ], numbers [0-9], symbols [ ], [/].

What is the principle of base64 encoding?

The principle of base64 encoding is:

Base64 encoding disassembles an 8-bit subsection sequence into 6-bit fragments. And allocate a character to each 6-bit fragment. These 64 characters-lowercase letters a-z, uppercase letters A-Z, numbers 0-9, symbols " ", "/". See here to know what 64 means. Well, it represents 64 characters. In fact, there is a pad "=", which is actually 65 characters.

Base64 rules are as follows:

The first step is to treat every three bytes as a group, a total of 24 binary bits.

The second step is to divide these 24 binary bits into four groups, each group has 6 binary bits.

The third step is to add two 00s in front of each group to expand it into 32 binary digits, that is, four bytes. Therefore, the base64 encoded string is about 33% larger than the original one

Example

Give a specific example to demonstrate how the English word Man is converted into Base64 encoding.

What is the principle of base64 encoding?

In the first step, the ASCII values ​​of "M", "a", and "n" are 77, 97, and 110 respectively, and the corresponding binary values ​​are 01001101 , 01100001, 01101110, concatenate them into a 24-bit binary string 010011010110000101101110.

The second step is to divide this 24-bit binary string into 4 groups, each group has 6 binary digits: 010011, 010110, 000101, 101110.

The third step is to add two 00s in front of each group to expand it into 32 binary digits, that is, four bytes: 00010011, 00010110, 00000101, 00101110. Their decimal values ​​are 19, 22, 5, and 46 respectively.

The fourth step, according to the figure below, get the Base64 encoding corresponding to each value, namely T, W, F, u.

Therefore, Man’s Base64 encoding is TWFu.

What is the principle of base64 encoding?

The above is the detailed content of What is the principle of base64 encoding?. For more information, please follow other related articles on the PHP Chinese website!

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
3 weeks agoBy尊渡假赌尊渡假赌尊渡假赌
WWE 2K25: How To Unlock Everything In MyRise
1 months agoBy尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Atom editor mac version download

Atom editor mac version download

The most popular open source editor

ZendStudio 13.5.1 Mac

ZendStudio 13.5.1 Mac

Powerful PHP integrated development environment

Safe Exam Browser

Safe Exam Browser

Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools