#base64 #hex #crypto

no-std ct-codecs

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

5 releases (3 stable)

1.1.1 Mar 20, 2021
1.1.0 Mar 19, 2021
1.0.0 Feb 19, 2021
0.1.1 May 20, 2020
0.1.0 Mar 23, 2020

#1519 in Cryptography

Download history 41955/week @ 2023-11-02 43833/week @ 2023-11-09 45691/week @ 2023-11-16 40741/week @ 2023-11-23 45096/week @ 2023-11-30 46853/week @ 2023-12-07 38346/week @ 2023-12-14 27983/week @ 2023-12-21 29452/week @ 2023-12-28 40640/week @ 2024-01-04 42164/week @ 2024-01-11 43362/week @ 2024-01-18 43453/week @ 2024-01-25 56671/week @ 2024-02-01 47874/week @ 2024-02-08 42189/week @ 2024-02-15

197,770 downloads per month
Used in 100 crates (12 directly)

MIT license

20KB
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.

API documentation

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