#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

#739 in Cryptography

Download history 9575/week @ 2022-06-01 12338/week @ 2022-06-08 10922/week @ 2022-06-15 10519/week @ 2022-06-22 13112/week @ 2022-06-29 15084/week @ 2022-07-06 15954/week @ 2022-07-13 16130/week @ 2022-07-20 15077/week @ 2022-07-27 15476/week @ 2022-08-03 15131/week @ 2022-08-10 16719/week @ 2022-08-17 17065/week @ 2022-08-24 16867/week @ 2022-08-31 15458/week @ 2022-09-07 16575/week @ 2022-09-14

68,305 downloads per month
Used in 12 crates (6 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

  • std