我经常听到人们谈论“64进制编码”。它的用途是什么?


当前回答

当需要对二进制数据进行编码时,通常使用Base64编码方案,这些数据需要通过设计用于处理文本数据的媒体存储和传输。这是为了确保数据在传输过程中保持完整而不被修改”(Wiki, 2017)

示例可能如下:您有一个只接受ASCII字符的web服务。你想要保存用户的数据,然后将其传输到其他位置(API),但接收者想要接收未触及的数据。Base64是用来…唯一的缺点是base64编码需要比常规字符串多33%的空间。

另一个示例::uenc = url encoded = aHR0cDovL2xvYy5tYWdlbnRvLmNvbS9hc2ljcy1tZW4tcy1nZWwta2F5YW5vLXhpaS5odG1s = http://loc.querytip.com/asics-men-s-gel-kayano-xii.html。

正如你所看到的,如果我们想把最后一次访问的URL作为参数发送,我们就不能把字符“/”放在URL中,因为我们会打破“MOD重写”- GET参数的属性/值规则。

一个完整的例子是:" http://loc.querytip.com/checkout/cart/add/uenc/http://loc.magento.com/asics-men-s-gel-kayano-xii.html/product/93/ "

其他回答

有些传输协议只允许传输字母数字字符。想象一下这样一种情况:控制字符用于触发特殊操作,或者每个字符只支持有限的位宽。Base64将任何输入转换为只使用字母数字字符、+、/和=作为填充字符的编码。

在计算机的早期,当电话线系统间的通信不是特别可靠时,一种快速而肮脏的验证数据完整性的方法被使用:“位奇偶校验”。在这种方法中,传输的每个字节都有7位数据,第8位将是1或0,以强制字节中1位的总数为偶数。

因此,0x01将作为0x81传输;0x02将是0x82;0x03仍然是0x03等等。

为了进一步完善这个系统,当定义ASCII字符集时,只有00-7F被分配字符。(直到今天,所有设置在80-FF范围内的字符都是非标准的)

当时的许多路由器都把奇偶校验和字节转换放在硬件中,迫使连接到它们的计算机严格处理7位数据。这迫使电子邮件附件(以及所有其他数据,这就是为什么HTTP和SMTP协议是基于文本的)转换为纯文本格式。

这些路由器很少能活到90年代。我非常怀疑它们中任何一个现在还在使用。

从http://en.wikipedia.org/wiki/Base64

The term Base64 refers to a specific MIME content transfer encoding. It is also used as a generic term for any similar encoding scheme that encodes binary data by treating it numerically and translating it into a base 64 representation. The particular choice of base is due to the history of character set encoding: one can choose a set of 64 characters that is both part of the subset common to most encodings, and also printable. This combination leaves the data unlikely to be modified in transit through systems, such as email, which were traditionally not 8-bit clean. Base64 can be used in a variety of contexts: Evolution and Thunderbird use Base64 to obfuscate e-mail passwords[1] Base64 can be used to transmit and store text that might otherwise cause delimiter collision Base64 is often used as a quick but insecure shortcut to obscure secrets without incurring the overhead of cryptographic key management Spammers use Base64 to evade basic anti-spamming tools, which often do not decode Base64 and therefore cannot detect keywords in encoded messages. Base64 is used to encode character strings in LDIF files Base64 is sometimes used to embed binary data in an XML file, using a syntax similar to ...... e.g. Firefox's bookmarks.html. Base64 is also used when communicating with government Fiscal Signature printing devices (usually, over serial or parallel ports) to minimize the delay when transferring receipt characters for signing. Base64 is used to encode binary files such as images within scripts, to avoid depending on external files. Can be used to embed raw image data into a CSS property such as background-image.

Base-64编码是一种获取二进制数据并将其转换为文本的方法,这样就更容易在电子邮件和HTML表单数据中传输。

http://en.wikipedia.org/wiki/Base64

它基本上是一种用ASCII文本编码任意二进制数据的方法。每3个字节的数据需要4个字符,最后可能还会有一些填充。

基本上,输入的每6位都用64个字符的字母表进行编码。“标准”字母表使用a-z, a-z, 0-9和+和/,用=作为填充字符。有url安全的变体。

维基百科是一个相当好的信息来源。