rust-auth-utils 1.0.0

A rust port of @better-auth/utils.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
use crate::hex::Hex;

#[test]
fn test_encode() {
    assert_eq!(Hex::encode("Hello"), "48656c6c6f");
    assert_eq!(Hex::encode([0xDE, 0xAD, 0xBE, 0xEF]), "deadbeef");
    assert_eq!(Hex::encode(""), "");
}

#[test]
fn test_decode() {
    assert_eq!(Hex::decode("48656c6c6f").unwrap(), b"Hello");
    assert_eq!(Hex::decode("").unwrap(), b"");
    assert!(Hex::decode("invalid").is_err());
    assert!(Hex::decode("123").is_err());
}