#base64 #hex #codec #crypto

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

#140 in Cryptography

Download history 77499/week @ 2024-10-30 77884/week @ 2024-11-06 75751/week @ 2024-11-13 77870/week @ 2024-11-20 72322/week @ 2024-11-27 80552/week @ 2024-12-04 80883/week @ 2024-12-11 65961/week @ 2024-12-18 42236/week @ 2024-12-25 61093/week @ 2025-01-01 82620/week @ 2025-01-08 80069/week @ 2025-01-15 80128/week @ 2025-01-22 77925/week @ 2025-01-29 84357/week @ 2025-02-05 69717/week @ 2025-02-12

326,565 downloads per month
Used in 151 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