#base64 #hex #constant-time-cryptography #base64-codec

no-std ct-codecs

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

7 releases (stable)

1.1.3 Dec 9, 2024
1.1.2 Aug 30, 2024
1.1.1 Mar 20, 2021
1.0.0 Feb 19, 2021
0.1.0 Mar 23, 2020

#85 in Cryptography

Download history 80776/week @ 2024-12-05 79972/week @ 2024-12-12 57601/week @ 2024-12-19 42619/week @ 2024-12-26 69920/week @ 2025-01-02 82915/week @ 2025-01-09 79894/week @ 2025-01-16 78882/week @ 2025-01-23 78853/week @ 2025-01-30 85425/week @ 2025-02-06 82704/week @ 2025-02-13 85606/week @ 2025-02-20 74093/week @ 2025-02-27 77519/week @ 2025-03-06 71674/week @ 2025-03-13 49673/week @ 2025-03-20

287,661 downloads per month
Used in 155 crates (15 directly)

MIT license

21KB
498 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.

Links:

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