Adobe 风格 Ascii85 把每四个字节转换为 ! 到 u 范围内的五个字符。本工具输出无包装文本,以 z 表示四个零字节,支持末尾短块,并可解码可选的 <~ ~> 包装和空白。
当二进制数据必须保持可打印时,Ascii85 约增加 25% 体积,比 Base64 的约 33% 更紧凑。其标点常需转义,Z85 等变体字母表不兼容,并且它不提供压缩、保密或完整性校验。
// npm install ascii85
const ascii85 = require('ascii85');
const encoded = ascii85.encode(Buffer.from('Hello')).toString();
console.log(encoded);
// Output: 87cURDZ
const decoded = ascii85.decode('87cURDZ').toString();
console.log(decoded);
// Output: Hello
package main
import (
"encoding/ascii85"
"fmt"
)
func main() {
dst := make([]byte, ascii85.MaxEncodedLen(len("Hello")))
n := ascii85.Encode(dst, []byte("Hello"))
encoded := string(dst[:n])
fmt.Println(encoded)
// Output: 87cURDZ
decoded := make([]byte, len("87cURDZ"))
n, _, _ = ascii85.Decode(decoded, []byte("87cURDZ"), true)
fmt.Println(string(decoded[:n]))
// Output: Hello
}
<?php
// composer require tuupola/base85
require 'vendor/autoload.php';
$base85 = new Tuupola\Base85;
$encoded = $base85->encode("Hello");
echo $encoded . "\n";
// Output: 87cURDZ
$decoded = $base85->decode("87cURDZ");
echo $decoded . "\n";
// Output: Hello