mirror of
https://codeberg.org/ziglang/zig.git
synced 2025-12-07 22:34:28 +00:00
This makes a few changes to the base64 codecs. * The padding character is optional. The common "URL-safe" variant, in particular, is generally not used with padding. This is also the case for password hashes, so having this will avoid code duplication with bcrypt, scrypt and other functions. * The URL-safe variant is added. Instead of having individual constants for each parameter of each variant, we are now grouping these in a struct. So, `standard_pad_char` just becomes `standard.pad_char`. * Types are not `snake_case`'d any more. So, `standard_encoder` becomes `standard.Encoder`, as it is a type. * Creating a decoder with ignored characters required the alphabet and padding. Now, `standard.decoderWithIgnore(<ignored chars>)` returns a decoder with the standard parameters and the set of ignored chars. * Whatever applies to `standard.*` obviously also works with `url_safe.*` * the `calcSize()` interface was inconsistent, taking a length in the encoder, and a slice in the encoder. Rename the variant that takes a slice to `calcSizeForSlice()`. * In the decoder with ignored characters, add `calcSizeUpperBound()`, which is more useful than the one that takes a slice in order to size a fixed buffer before we have the data. * Return `error.InvalidCharacter` when the input actually contains characters that are neither padding nor part of the alphabet. If we hit a padding issue (which includes extra bits at the end), consistently return `error.InvalidPadding`. * Don't keep the `char_in_alphabet` array permanently in a decoder; it is only required for sanity checks during initialization. * Tests are unchanged, but now cover both the standard (padded) and the url-safe (non-padded) variants. * Add an error set, rename `OutputTooSmallError` to `NoSpaceLeft` to match the `hex2bin` equivalent. |
||
|---|---|---|
| .. | ||
| atomic | ||
| build | ||
| c | ||
| compress | ||
| crypto | ||
| event | ||
| fmt | ||
| fs | ||
| hash | ||
| heap | ||
| io | ||
| json | ||
| math | ||
| mem | ||
| meta | ||
| net | ||
| os | ||
| rand | ||
| special | ||
| target | ||
| testing | ||
| Thread | ||
| time | ||
| unicode | ||
| valgrind | ||
| zig | ||
| array_hash_map.zig | ||
| array_list.zig | ||
| ascii.zig | ||
| atomic.zig | ||
| base64.zig | ||
| bit_set.zig | ||
| buf_map.zig | ||
| buf_set.zig | ||
| build.zig | ||
| builtin.zig | ||
| c.zig | ||
| child_process.zig | ||
| coff.zig | ||
| compress.zig | ||
| comptime_string_map.zig | ||
| crypto.zig | ||
| cstr.zig | ||
| debug.zig | ||
| dwarf.zig | ||
| dwarf_bits.zig | ||
| dynamic_library.zig | ||
| elf.zig | ||
| enums.zig | ||
| event.zig | ||
| fifo.zig | ||
| fmt.zig | ||
| fs.zig | ||
| hash.zig | ||
| hash_map.zig | ||
| heap.zig | ||
| io.zig | ||
| json.zig | ||
| leb128.zig | ||
| linked_list.zig | ||
| log.zig | ||
| macho.zig | ||
| math.zig | ||
| mem.zig | ||
| meta.zig | ||
| multi_array_list.zig | ||
| net.zig | ||
| once.zig | ||
| os.zig | ||
| packed_int_array.zig | ||
| pdb.zig | ||
| priority_queue.zig | ||
| process.zig | ||
| Progress.zig | ||
| rand.zig | ||
| SemanticVersion.zig | ||
| sort.zig | ||
| start.zig | ||
| start_windows_tls.zig | ||
| std.zig | ||
| target.zig | ||
| testing.zig | ||
| Thread.zig | ||
| time.zig | ||
| unicode.zig | ||
| valgrind.zig | ||
| wasm.zig | ||
| zig.zig | ||