什么是 base 64 编码? [英] What is base 64 encoding used for?

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

问题描述

我听说人们到处谈论base 64 编码".有什么用?

I've heard people talking about "base 64 encoding" here and there. What is it used for?

推荐答案

当您想要通过网络传输一些二进制数据时,您通常不会仅仅通过网络传输位和字节来实现原始格式.为什么?因为有些媒体是为流文本而制作的.您永远不知道——某些协议可能会将您的二进制数据解释为控制字符(例如调制解调器),或者您的二进制数据可能会被搞砸,因为底层协议可能认为您输入了特殊字符组合(例如 FTP 如何转换行结局).

When you have some binary data that you want to ship across a network, you generally don't do it by just streaming the bits and bytes over the wire in a raw format. Why? because some media are made for streaming text. You never know -- some protocols may interpret your binary data as control characters (like a modem), or your binary data could be screwed up because the underlying protocol might think that you've entered a special character combination (like how FTP translates line endings).

所以为了解决这个问题,人们将二进制数据编码为字符.Base64 是这些类型的编码之一.

So to get around this, people encode the binary data into characters. Base64 is one of these types of encodings.

为什么是 64?
因为您通常可以依赖存在于许多字符集中的相同 64 个字符,并且您可以合理地确信您的数据将在未损坏的线路的另一端结束.

Why 64?
Because you can generally rely on the same 64 characters being present in many character sets, and you can be reasonably confident that your data's going to end up on the other side of the wire uncorrupted.

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

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