#base64 #hex #codec #crypto

no-std ct-codecs

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

7 releases (stable)

new 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

#166 in Cryptography

Download history 65037/week @ 2024-08-19 64300/week @ 2024-08-26 68502/week @ 2024-09-02 74210/week @ 2024-09-09 188918/week @ 2024-09-16 121568/week @ 2024-09-23 449275/week @ 2024-09-30 744896/week @ 2024-10-07 611000/week @ 2024-10-14 194145/week @ 2024-10-21 77790/week @ 2024-10-28 78929/week @ 2024-11-04 75081/week @ 2024-11-11 77008/week @ 2024-11-18 71241/week @ 2024-11-25 76083/week @ 2024-12-02

303,894 downloads per month
Used in 137 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