search
HomeCommon ProblemWhat is the use of base64 encoding?

The uses of base64 encoding: 1. Convert non-ASCII character data into ASCII characters; 2. Especially suitable for fast data transmission under http and mime protocols; 3. The data content is encoded for transmission, which is safe and simple .

What is the use of base64 encoding?

Use of base64 encoding:

1. Function of Base64

  • Because only ASCII characters can be used in some systems. Base64 is a method used to convert non-ASCII character data into ASCII characters.

  • base64 is particularly suitable for fast data transmission under http and mime protocols.

  • base64 is actually not an encryption and decryption algorithm in the security field. Although sometimes we often see so-called base64 encryption and decryption. In fact, base64 can only be regarded as an encoding algorithm, encoding the data content to suit transmission. Although the original text becomes an invisible character format after base64 encoding, this method is very elementary and simple.

##2. Base64 encoding application

Base64 encoding can be used to transmit longer identification information in the

HTTP environment. For example, in Java Persistence systemHibernate, Base64 is used to encode a longer unique identifier (usually a 128-bit UUID) into a string, using Make parameters in HTTP form and HTTP GET URL. In other applications, it is often necessary to encode binary data into a form suitable for placement in a URL (including hidden form fields). At this time, using Base64 encoding is not only shorter, but also unreadable, that is, the encoded data will not be directly visible to the naked eye.

However, standard Base64 is not suitable for transmission directly in the URL, because the URL encoder will change the "/" and " " characters in standard Base64 into the form of "%XX", and These "%" signs need to be converted when they are stored in the database, because the "%" sign has been used as a wildcard character in

ANSI SQL.

To solve this problem, an improved Base64 encoding for URLs can be used. It not only removes the padded '=' sign at the end, but also changes the " " and "/" in standard Base64 to "-" and "_" are eliminated, which eliminates the need for conversion during URL encoding, decoding and database storage, avoids the increase in the length of encoded information in the process, and unifies object identifiers in databases, forms, etc. format.

There is another improved Base64 variant for regular expressions, which changes " " and "/" to "!" and "-", because " ", "*" and the preceding ones are in IRCu The "[" and "]" used in regular expressions may have special meanings.

There are also some variants that change "/" to "_-" or "._" (used as an identifier name in programming languages) or ".-" (used in XML Nmtoken) or even "_:" (for Name in XML).

3. Other applications

1) Mozilla Thunderbird and Evolution use Base64 to keep email passwords secret

2) Base64 is also often used as a Simple "encryption" protects some data, while real encryption is often more cumbersome.

 3) Spammers use Base64 to evade anti-spam tools, because those tools usually do not translate Base64 messages.

 4) In LDIF files, Base64 is used as the encoded string.

The above is the detailed content of What is the use 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

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

MantisBT

MantisBT

Mantis is an easy-to-deploy web-based defect tracking tool designed to aid in product defect tracking. It requires PHP, MySQL and a web server. Check out our demo and hosting services.

mPDF

mPDF

mPDF is a PHP library that can generate PDF files from UTF-8 encoded HTML. The original author, Ian Back, wrote mPDF to output PDF files "on the fly" from his website and handle different languages. It is slower than original scripts like HTML2FPDF and produces larger files when using Unicode fonts, but supports CSS styles etc. and has a lot of enhancements. Supports almost all languages, including RTL (Arabic and Hebrew) and CJK (Chinese, Japanese and Korean). Supports nested block-level elements (such as P, DIV),

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

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.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.