base64为了解决邮件传输中,将图片转化为文本
Base64编码是从二进制到字符的过程,可用于在HTTP环境下传递较长的标识信息。
可用于在互联网传输图片、文件等。
参考自:base64_百度百科
Encodes the given string
with base64.
This encoding is designed to make binary data survive transport through transport layers that are not 8-bit clean, such as mail bodies.
Base64-encoded data takes about 33% more space than the original data.
参考自:
相关历史:
几年前,当引入邮件功能时,它完全基于文本,随着时间的推移,对图像和媒体(音频、视频等)等附件的需求出现了。 当这些附件通过互联网(基本上以二进制数据的形式)发送时,二进制数据在其原始形式中被破坏的可能性很高。 所以,为了解决这个问题,BASE64 出现了。
二进制数据的问题在于它包含空字符,在某些语言(如 C、C++)中表示字符串的结尾,因此以包含 NULL 字节的原始格式发送二进制数据将阻止文件被完全读取并导致数据损坏
Years ago, when mailing functionality was introduced, so that was utterly text based, as the time passed, need for attachments like image and media (audio,video etc) came into existence. When these attachments are sent over internet (which is basically in the form of binary data), the probability of binary data getting corrupt is high in its raw form. So, to tackle this problem BASE64 came along.
The problem with binary data is that it contains null characters which in some languages like C,C++ represent end of character string so sending binary data in raw form containing NULL bytes will stop a file from being fully read and lead in a corrupt data
参考自:
base64 - What is base 64 encoding used for? - Stack Overflow