Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
265 views
in Technique[技术] by (71.8m points)

encoding - base 64编码用于什么?(What is base 64 encoding used for?)

I've heard people talking about "base 64 encoding" here and there.

(我听说有人在这里和那里谈论“base 64编码”。)

What is it used for?

(它是干什么用的?)

  ask by MrDatabase translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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).

(你永远不会知道 - 某些协议可能会将你的二进制数据解释为控制字符(如调制解调器),或者你的二进制数据可能被搞砸了,因为底层协议可能认为你输入了一个特殊的字符组合(比如FTP如何转换行)结局)。)

So to get around this, people encode the binary data into characters.

(因此,为了解决这个问题,人们将二进制数据编码为字符。)

Base64 is one of these types of encodings.

(Base64是这些类型的编码之一。)

Why 64?

(为什么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.

(因为您通常可以依赖于许多字符集中存在的相同64个字符,并且您可以合理地确信您的数据最终会在线路的另一端不受损坏。)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...