#base64 #hex #crypto

no-std ct-codecs

Constant-time hex and base64 codecs from libsodium reimplemented in Rust

5 releases (3 stable)

1.1.1 Mar 20, 2021
1.1.0 Mar 19, 2021
1.0.0 Feb 19, 2021
0.1.1 May 20, 2020
0.1.0 Mar 23, 2020

#12 in #base64

Download history 48139/week @ 2023-12-06 38891/week @ 2023-12-13 30457/week @ 2023-12-20 26829/week @ 2023-12-27 39931/week @ 2024-01-03 42177/week @ 2024-01-10 42749/week @ 2024-01-17 42956/week @ 2024-01-24 56753/week @ 2024-01-31 47452/week @ 2024-02-07 49916/week @ 2024-02-14 53925/week @ 2024-02-21 60485/week @ 2024-02-28 64730/week @ 2024-03-06 66790/week @ 2024-03-13 54352/week @ 2024-03-20

256,216 downloads per month
Used in 104 crates (12 directly)

MIT license

20KB
488 lines

CT-Codecs

A reimplementation of the base64 and hexadecimal codecs from libsodium and libhydrogen in Rust.

  • Constant-time for a given length, suitable for cryptographic purposes
  • Strict (base64 strings are not malleable)
  • Supports padded and unpadded, original and URL-safe base64 variants
  • Supports characters to be ignored by the decoder
  • Zero dependencies, no_std friendly.

API documentation

Example usage

use ct_codecs::{Base64UrlSafe, Decoder, Encoder};

let encoded = Base64UrlSafe::encode_to_string(x)?;
let decoded = Base64UrlSafe::decode_to_vec(encoded, None)?;

lib.rs:

Constant-time codecs.

No runtime deps

Features