#base64 #hex #codec #crypto

no-std ct-codecs

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

6 releases (stable)

1.1.2 Aug 30, 2024
1.1.1 Mar 20, 2021
1.0.0 Feb 19, 2021
0.1.1 May 20, 2020
0.1.0 Mar 23, 2020

#143 in Cryptography

Download history 63983/week @ 2024-07-30 62756/week @ 2024-08-06 62091/week @ 2024-08-13 63498/week @ 2024-08-20 63281/week @ 2024-08-27 72934/week @ 2024-09-03 73156/week @ 2024-09-10 224884/week @ 2024-09-17 177114/week @ 2024-09-24 518972/week @ 2024-10-01 709241/week @ 2024-10-08 548361/week @ 2024-10-15 133206/week @ 2024-10-22 77005/week @ 2024-10-29 77875/week @ 2024-11-05 63213/week @ 2024-11-12

426,130 downloads per month
Used in 136 crates (13 directly)

MIT license

21KB
488 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