#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

#184 in Cryptography

Download history 229127/week @ 2024-09-20 232706/week @ 2024-09-27 647632/week @ 2024-10-04 531686/week @ 2024-10-11 574221/week @ 2024-10-18 101885/week @ 2024-10-25 78551/week @ 2024-11-01 75192/week @ 2024-11-08 79016/week @ 2024-11-15 72306/week @ 2024-11-22 77868/week @ 2024-11-29 81686/week @ 2024-12-06 78371/week @ 2024-12-13 51136/week @ 2024-12-20 46233/week @ 2024-12-27 60005/week @ 2025-01-03

250,450 downloads per month
Used in 142 crates (13 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