#base64 #bases #base #rfc-4648 #基于 #文档编写的 #编码解码库

bases64

Base64 base on RFC4648 基于 RFC4648 文档编写的 Base64 编码解码库

1 unstable release

0.1.0 Aug 21, 2019

#9 in #bases

MIT/Apache

4.5MB
506 lines

Contains (WOFF font, 190KB) target/doc/FiraSans-Medium.woff, (WOFF font, 185KB) target/doc/FiraSans-Regular.woff, (WOFF font, 94KB) target/doc/SourceSerifPro-Bold.ttf.woff, (WOFF font, 89KB) SourceSerifPro-Regular.ttf.woff, (WOFF font, 56KB) target/doc/SourceCodePro-Regular.woff, (WOFF font, 56KB) target/doc/SourceCodePro-Semibold.woff and 1 more.

bases

Rust-lang: The bases crate base on RFC4648

bases 库是基于规范文档 RFC4648 编写的库

This crate is very simple

这个库非常简单易用

Usually, we use encode () and decode (). But if Base64 is used for URLs, encode_url() and decode_url() should be used.

通常情况下,我们会用到 encode() 和 decode()。但如果 Base64 被用于 URL,那么就应该使用 encode_url() 和 decode_url()

Documents

GitHub - RFCBase64

Usage 使用方法

encode

Given a string, return an encode result. This is the inverse of decode().

decode

Given a String, return a decode result, it's original of encode(). This is the inverse of decode().

encode_url

Like encode(), this is for url.

decode_url

Like decode(), this is for url

encode()

&str to String, "Bruce Done say: Hi,I'm frank。" -> "QnJ1Y2UgRG9uZSBzYXk6IEhpLEknbSBmcmFua+OAgg=="

Example

use bases64::bases::Bases;
let bases = Bases{};
let res = bases.encode("Bruce Done say: Hi,I'm frank。");
assert_eq!(res, String::from("QnJ1Y2UgRG9uZSBzYXk6IEhpLEknbSBmcmFua+OAgg=="));

decode()

String to String, "QnJ1Y2UgRG9uZSBzYXk6IEhpLEknbSBmcmFua+OAgg==" -> "Bruce Done say: Hi,I'm frank。"

Example

use bases64::bases::Bases;
let bases = Bases{};
let res = bases.decode(String::from("QnJ1Y2UgRG9uZSBzYXk6IEhpLEknbSBmcmFua+OAgg=="));
assert_eq!(res, String::from("Bruce Done say: Hi,I'm frank。"));

encode_url()

For url.

&str to String, "Bruce Done say: Hi,I'm frank。" -> "QnJ1Y2UgRG9uZSBzYXk6IEhpLEknbSBmcmFua-OAgg=="

Example

use bases64::bases::Bases;
let bases = Bases{};
let res = bases.encode_url("Bruce Done say: Hi,I'm frank。");
assert_eq!(res, String::from("QnJ1Y2UgRG9uZSBzYXk6IEhpLEknbSBmcmFua-OAgg=="));

decode_url()

For url.

Example

use bases64::bases::Bases;
let bases = Bases{};
let res = bases.decode_url(String::from("QnJ1Y2UgRG9uZSBzYXk6IEhpLEknbSBmcmFua-OAgg=="));
assert_eq!(res, String::from("Bruce Done say: Hi,I'm frank。"));

No runtime deps