1#![doc = include_str!("../README.md")]
2#![allow(clippy::new_without_default)]
3
4use rand::Rng;
5
6#[cfg(feature = "b64")]
8use std::str::FromStr;
9
10use crate::utils::SysRngPanic;
11
12#[cfg(feature = "cipher")]
13pub mod cipher;
14
15#[cfg(feature = "signature")]
16pub mod signature;
17
18#[cfg(feature = "hash")]
19pub mod hash;
20
21pub mod token;
22
23pub mod error;
24
25mod utils;
26
27pub fn xor(buf: &mut [u8], key: &[u8]) {
33 assert_eq!(buf.len(), key.len());
34
35 for (a, b) in buf.iter_mut().zip(key) {
36 *a ^= *b;
37 }
38}
39
40pub fn fill_random(buf: &mut [u8]) {
47 SysRngPanic.fill_bytes(buf)
48}
49
50#[inline(always)]
54const fn calculate_b64_len(s: usize) -> usize {
55 (4 * s).div_ceil(3)
56}