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天全站免登陆