Cryptography Utils for Rust
You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Go to file
renovate[bot] aa63351a23 fix(deps): update rust crate serde to 1.0.152 5 months ago
.github/workflows chore(release): v0.4.1 9 months ago
examples chore(examples): add hmac in sha example 11 months ago
src chore(release): v0.4.1 9 months ago
.gitignore chore: add examples 12 months ago
Cargo.lock fix(deps): update rust crate serde to 1.0.152 5 months ago
Cargo.toml fix(deps): update rust crate serde to 1.0.152 5 months ago
LICENSE initial commit 12 months ago
README.md chore(release): v0.4.1 9 months ago
renovate.json chore: setup renovatebot 12 months ago

README.md

Cryptography Utils for Rust

github crates-io docs-rs ci

Cryptography Utils for Rust

Importing

The driver is available on crates.io. To use the driver in your application, simply add it to your project's Cargo.toml.

[dependencies]
crypto-utils = "0.4.1"

How to use?

Compute a Sha hash

Quick and easy Sha1, Sha256 and Sha512 hash computing.

use crypto_utils::sha::{Algorithm, CryptographicHash};

// input data for a hasher
let input = "P@ssw0rd"; // &str

// compute hash
let hash_bytes = CryptographicHash::hash(Algorithm::SHA1, input.as_bytes()); // Vec<u8>

// decode hash to a String
let hash = hex::encode(hash_bytes); // String

assert_eq!(hash, "21bd12dc183f740ee76f27b78eb39c8ad972a757".to_string())

Json Web Token

Create and decode a token

use crypto_utils::jsonwebtoken::{Claims, Token};

let secret = b"secret";
let user_id = "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx";

let claims = Claims::new(user_id, 24);
let token = Token::new(secret, claims).unwrap();

let decoded = Token::decode(secret, token.encoded).unwrap();

All Feature flags

Feature Description Dependencies Default
sha Enable support for the Sha1, Sha256 and Sha512 hasher sha and sha2 yes
jwt Enable support for the Json Web Token utils chrono, serde and jsonwebtoken yes

License: MIT