Skip to content

Commit 654c6b3

Browse files
committed
Add BASE32_NOPAD_INSENSITIVE and BASE32_NOPAD_PERMISSIVE
1 parent a22931a commit 654c6b3

File tree

8 files changed

+120
-26
lines changed

8 files changed

+120
-26
lines changed

bin/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.3.6-git
4+
5+
### Patch
6+
7+
- Update `data-encoding` version
8+
39
## 0.3.5
410

511
### Minor

bin/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "data-encoding-bin"
3-
version = "0.3.5"
3+
version = "0.3.6-git"
44
authors = ["Julien Cretin <[email protected]>"]
55
license = "MIT"
66
edition = "2021"
@@ -17,5 +17,5 @@ name = "data-encoding"
1717
path = "src/main.rs"
1818

1919
[dependencies]
20-
data-encoding = { version = "2.7.0", path = "../lib" }
20+
data-encoding = { version = "2.8.0-git", path = "../lib" }
2121
getopts = "0.2"

lib/CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 2.8.0-git
4+
5+
### Minor
6+
7+
- Add `BASE32_NOPAD_NOCASE` and `BASE32_NOPAD_VISUAL`
8+
39
## 2.7.0
410

511
### Minor

lib/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "data-encoding"
3-
version = "2.7.0"
3+
version = "2.8.0-git"
44
authors = ["Julien Cretin <[email protected]>"]
55
license = "MIT"
66
edition = "2018"

lib/README.md

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,26 @@
33

44
This library provides the following common encodings:
55

6-
| Name | Description |
7-
|--------------------------|---------------------------------------------------|
8-
| `HEXLOWER` | lowercase hexadecimal |
9-
| `HEXLOWER_PERMISSIVE` | lowercase hexadecimal (case-insensitive decoding) |
10-
| `HEXUPPER` | uppercase hexadecimal |
11-
| `HEXUPPER_PERMISSIVE` | uppercase hexadecimal (case-insensitive decoding) |
12-
| `BASE32` | RFC4648 base32 |
13-
| `BASE32_NOPAD` | RFC4648 base32 (no padding) |
14-
| `BASE32_DNSSEC` | RFC5155 base32 |
15-
| `BASE32_DNSCURVE` | DNSCurve base32 |
16-
| `BASE32HEX` | RFC4648 base32hex |
17-
| `BASE32HEX_NOPAD` | RFC4648 base32hex (no padding) |
18-
| `BASE64` | RFC4648 base64 |
19-
| `BASE64_NOPAD` | RFC4648 base64 (no padding) |
20-
| `BASE64_MIME` | RFC2045-like base64 |
21-
| `BASE64_MIME_PERMISSIVE` | RFC2045-like base64 (ignoring trailing bits) |
22-
| `BASE64URL` | RFC4648 base64url |
23-
| `BASE64URL_NOPAD` | RFC4648 base64url (no padding) |
6+
| Name | Description |
7+
|--------------------------|--------------------------------------------------------|
8+
| `HEXLOWER` | lowercase hexadecimal |
9+
| `HEXLOWER_PERMISSIVE` | lowercase hexadecimal (case-insensitive decoding) |
10+
| `HEXUPPER` | uppercase hexadecimal |
11+
| `HEXUPPER_PERMISSIVE` | uppercase hexadecimal (case-insensitive decoding) |
12+
| `BASE32` | RFC4648 base32 |
13+
| `BASE32_NOPAD` | RFC4648 base32 (no padding) |
14+
| `BASE32_NOPAD_NOCASE` | RFC4648 base32 (no padding, case-insensitive decoding) |
15+
| `BASE32_NOPAD_VISUAL` | RFC4648 base32 (no padding, visual-approx. decoding) |
16+
| `BASE32HEX` | RFC4648 base32hex |
17+
| `BASE32HEX_NOPAD` | RFC4648 base32hex (no padding) |
18+
| `BASE32_DNSSEC` | RFC5155 base32 |
19+
| `BASE32_DNSCURVE` | DNSCurve base32 |
20+
| `BASE64` | RFC4648 base64 |
21+
| `BASE64_NOPAD` | RFC4648 base64 (no padding) |
22+
| `BASE64_MIME` | RFC2045-like base64 |
23+
| `BASE64_MIME_PERMISSIVE` | RFC2045-like base64 (ignoring trailing bits) |
24+
| `BASE64URL` | RFC4648 base64url |
25+
| `BASE64URL_NOPAD` | RFC4648 base64url (no padding) |
2426

2527
It also provides the possibility to define custom little-endian ASCII
2628
base-conversion encodings for bases of size 2, 4, 8, 16, 32, and 64 (for which

lib/macro/Cargo.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "data-encoding-macro"
3-
version = "0.1.16"
3+
version = "0.1.17-git"
44
authors = ["Julien Cretin <[email protected]>"]
55
license = "MIT"
66
edition = "2018"
@@ -14,5 +14,5 @@ description = "Macros for data-encoding"
1414
include = ["Cargo.toml", "LICENSE", "README.md", "src/lib.rs"]
1515

1616
[dependencies]
17-
data-encoding = { version = "2.7.0", path = "..", default-features = false }
18-
data-encoding-macro-internal = { version = "0.1.14", path = "internal" }
17+
data-encoding = { version = "2.8.0-git", path = "..", default-features = false }
18+
data-encoding-macro-internal = { version = "0.1.15-git", path = "internal" }

lib/macro/internal/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "data-encoding-macro-internal"
3-
version = "0.1.14"
3+
version = "0.1.15-git"
44
authors = ["Julien Cretin <[email protected]>"]
55
license = "MIT"
66
edition = "2018"
@@ -14,7 +14,7 @@ include = ["Cargo.toml", "LICENSE", "README.md", "src/lib.rs"]
1414
proc-macro = true
1515

1616
[dependencies.data-encoding]
17-
version = "2.7.0"
17+
version = "2.8.0-git"
1818
path = "../.."
1919
default-features = false
2020
features = ["alloc"]

lib/src/lib.rs

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2154,6 +2154,86 @@ const BASE32_NOPAD_IMPL: &[u8] = &[
21542154
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,
21552155
];
21562156

2157+
/// Unpadded base32 encoding with case-insensitive decoding
2158+
///
2159+
/// This encoding is a static version of:
2160+
///
2161+
/// ```rust
2162+
/// # use data_encoding::{Specification, BASE32_NOPAD_NOCASE};
2163+
/// let mut spec = Specification::new();
2164+
/// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
2165+
/// spec.translate.from.push_str("abcdefghijklmnopqrstuvwxyz");
2166+
/// spec.translate.to.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ");
2167+
/// assert_eq!(BASE32_NOPAD_NOCASE, spec.encoding().unwrap());
2168+
/// ```
2169+
pub const BASE32_NOPAD_NOCASE: Encoding = Encoding::internal_new(BASE32_NOPAD_NOCASE_IMPL);
2170+
const BASE32_NOPAD_NOCASE_IMPL: &[u8] = &[
2171+
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2172+
89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2173+
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
2174+
73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
2175+
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2176+
89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2177+
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
2178+
73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
2179+
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2180+
89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2181+
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,
2182+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2183+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2184+
128, 128, 128, 128, 128, 128, 26, 27, 28, 29, 30, 31, 128, 128, 128, 128, 128, 128, 128, 128,
2185+
128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24,
2186+
25, 128, 128, 128, 128, 128, 128, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17,
2187+
18, 19, 20, 21, 22, 23, 24, 25, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2188+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2189+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2190+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2191+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2192+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2193+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2194+
128, 128, 128, 128, 128, 128, 128, 128, 29,
2195+
];
2196+
2197+
/// Unpadded base32 encoding with visual error correction during decoding
2198+
///
2199+
/// This encoding is a static version of:
2200+
///
2201+
/// ```rust
2202+
/// # use data_encoding::{Specification, BASE32_NOPAD_VISUAL};
2203+
/// let mut spec = Specification::new();
2204+
/// spec.symbols.push_str("ABCDEFGHIJKLMNOPQRSTUVWXYZ234567");
2205+
/// spec.translate.from.push_str("01l8");
2206+
/// spec.translate.to.push_str("OIIB");
2207+
/// assert_eq!(BASE32_NOPAD_VISUAL, spec.encoding().unwrap());
2208+
/// ```
2209+
pub const BASE32_NOPAD_VISUAL: Encoding = Encoding::internal_new(BASE32_NOPAD_VISUAL_IMPL);
2210+
const BASE32_NOPAD_VISUAL_IMPL: &[u8] = &[
2211+
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2212+
89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2213+
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
2214+
73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
2215+
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2216+
89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2217+
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72,
2218+
73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55,
2219+
65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88,
2220+
89, 90, 50, 51, 52, 53, 54, 55, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80,
2221+
81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 50, 51, 52, 53, 54, 55, 128, 128, 128, 128, 128, 128,
2222+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2223+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2224+
128, 128, 128, 128, 14, 8, 26, 27, 28, 29, 30, 31, 1, 128, 128, 128, 128, 128, 128, 128, 128,
2225+
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25,
2226+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 8, 128,
2227+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2228+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2229+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2230+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2231+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2232+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2233+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128,
2234+
128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 128, 29,
2235+
];
2236+
21572237
/// Padded base32hex encoding
21582238
///
21592239
/// This encoding is a static version of:

0 commit comments

Comments
 (0)