Base64编码的真正目的是什么? [英] What is the real purpose of Base64 encoding?

查看:497
本文介绍了Base64编码的真正目的是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为什么我们要使用Base64编码?我是一个初学者,我真的不明白为什么您会将字节混淆成其他东西(除非是加密的).在我读过的其中一本书中,当不可能进行二进制传输时,Base64编码很有用.例如.当我们发布表单时,它会被编码.但是为什么我们将字节转换为字母呢?我们不能只是将字节转换为字符串格式而在两者之间留有空格吗?例如,00000001 00000004?还是只是0000000100000004而没有任何空格,因为字节总是成对出现在8对中?

Why do we have Base64 encoding? I am a beginner and I really don't understand why would you obfuscate the bytes into something else (unless it is encryption). In one of the books I read Base64 encoding is useful when binary transmission is not possible. Eg. When we post a form it is encoded. But why do we convert bytes into letters? Couldn't we just convert bytes into string format with a space in between? For example, 00000001 00000004? Or simply 0000000100000004 without any space because bytes always come in pair of 8?

推荐答案

Base64是一种将二进制数据编码为几乎每个计算机系统都知道的ASCII字符集的方法,以便传输数据而不会丢失或修改内容本身. 例如,邮件系统无法处理二进制数据,因为它们需要ASCII(文本)数据.因此,如果您要传输图像或其他文件,由于其处理数据的方式,它将被损坏.

Base64 is a way to encode binary data into an ASCII character set known to pretty much every computer system, in order to transmit the data without loss or modification of the contents itself. For example, mail systems cannot deal with binary data because they expect ASCII (textual) data. So if you want to transfer an image or another file, it will get corrupted because of the way it deals with the data.

注意:base64编码既不是加密方法,也不是压缩数据的方法.实际上,以base64编码的数据段比原始数据段大1.333倍.这是确保传输过程中不会丢失或修改任何数据的一种方法.

Note: base64 encoding is NOT a way of encrypting, nor a way of compacting data. In fact a base64 encoded piece of data is 1.333… times bigger than the original datapiece. It is only a way to be sure that no data is lost or modified during the transfer.

这篇关于Base64编码的真正目的是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆