#base64 #web-api #byte-array #access-control #serialization

aliri_base64

Wrappers that make debugging and using byte arrays a bit nicer

9 releases

0.1.8 Apr 12, 2024
0.1.7 May 27, 2023
0.1.6 Jun 15, 2022
0.1.5 Feb 21, 2022
0.1.3 Apr 29, 2021

#1659 in Encoding

Download history 31107/week @ 2024-07-20 26030/week @ 2024-07-27 23373/week @ 2024-08-03 23501/week @ 2024-08-10 22155/week @ 2024-08-17 24292/week @ 2024-08-24 21699/week @ 2024-08-31 25119/week @ 2024-09-07 23287/week @ 2024-09-14 27485/week @ 2024-09-21 29070/week @ 2024-09-28 27329/week @ 2024-10-05 29829/week @ 2024-10-12 29035/week @ 2024-10-19 29497/week @ 2024-10-26 22959/week @ 2024-11-02

116,873 downloads per month
Used in 8 crates (4 directly)

MIT/Apache

23KB
289 lines

Aliri Base64

Esperanto for "access"

CI

Aliri is a family of crates intended to help build access control, particularly of web APIs, where a token is the primary means of providing access.

Features

The aliri_base64 crate provides some utilities for more easily working with byte arrays and buffers that need to be serialized using Base64 encoding. This is particularly necessary for many of the types that aliri works with, but may also be of use to others as well.

The underlying encoding/decoding mechanism is provided by the base64 crate.

Supported encodings

Base64 and Base64Ref wrap owned and borrowed byte arrays that must be serialized in the standard Base64 encoding with padding.

Base64Url and Base64UrlRef wrap owned and borrowed byte arrays that must be serialized in the URL-safe Base64 encoding with no padding.

Additional encodings may be added in the future, but these were the two primary encodings required to support my base set of use cases.

Unsafe code

Aliri Base64 makes use of two lines of unsafe code. This unsafe code is limited to the functions that allow the Base64Ref and Base64UrlRef to wrap borrowed byte slices. This reinterpretation is safe because these types are transparent wrappers around [u8], use #[repr(transparent)], and thus share the exact same representation as the underlying slice. This is currently necessary as there is currently no way to transmute equivalent representations of dynamically sized values in safe Rust.

For the above reason, this crate uses #![deny(unsafe_code)] rather than #![forbid(unsafe_code)]. The only #![allow(unsafe_code)] in the crate can be located in the private b64_builder! macro.

Note that, because cargo-geiger has difficulty parsing out unsafe usage from within macros, that tool won't report these crates as "radioactive", but probably should. Do your due diligence.

Dependencies

~215–395KB