Expand description
§Utility Functions for Cryptographic Operations
This module provides common utility functions used throughout the RusCrypt library, including encoding/decoding, padding, and character manipulation functions.
§Features
- Encoding: Base64 and hexadecimal encoding/decoding
- Padding: PKCS#7 padding for block ciphers
- Character operations: Caesar cipher character shifting
§Examples
use ruscrypt::utils::{to_base64, from_base64, to_hex, from_hex};
let data = b"Hello, World!";
let base64 = to_base64(data);
let decoded = from_base64(&base64).unwrap();
assert_eq!(data, &decoded[..]);Functions§
- from_
base64 - Decodes a Base64 string to binary data.
- from_
hex - Converts a hexadecimal string to binary data.
- pad_
data - Pads data to 16-byte blocks using PKCS#7 padding.
- pad_
data_ to_ size - Pads data to the specified block size using PKCS#7 padding.
- remove_
padding - Removes PKCS#7 padding from padded data.
- shift_
char - Shifts a single character by the specified amount for Caesar cipher.
- to_
base64 - Encodes binary data to a Base64 string.
- to_hex
- Converts binary data to a lowercase hexadecimal string.