#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

#159 in Cryptography

Download history 712942/week @ 2024-10-06 579406/week @ 2024-10-13 359401/week @ 2024-10-20 77930/week @ 2024-10-27 79274/week @ 2024-11-03 74966/week @ 2024-11-10 76763/week @ 2024-11-17 70611/week @ 2024-11-24 81293/week @ 2024-12-01 80982/week @ 2024-12-08 78588/week @ 2024-12-15 44036/week @ 2024-12-22 49680/week @ 2024-12-29 78620/week @ 2025-01-05 84170/week @ 2025-01-12 78283/week @ 2025-01-19

295,297 downloads per month
Used in 145 crates (14 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