feat: create crypto.rs module for generation of tokens
This commit is contained in:
parent
c69f2eb4f0
commit
a88467fa28
3 changed files with 17 additions and 0 deletions
|
@ -13,6 +13,8 @@ actix-web = "4.10"
|
|||
argon2 = { version = "0.5.3", features = ["std"] }
|
||||
clap = { version = "4.5.37", features = ["derive"] }
|
||||
futures = "0.3"
|
||||
getrandom = "0.3.2"
|
||||
hex = "0.4.3"
|
||||
regex = "1.11"
|
||||
serde = { version = "1.0", features = ["derive"] }
|
||||
serde_json = "1.0"
|
||||
|
|
14
src/crypto.rs
Normal file
14
src/crypto.rs
Normal file
|
@ -0,0 +1,14 @@
|
|||
use getrandom::fill;
|
||||
use hex::encode;
|
||||
|
||||
fn generate_access_token() -> Result<String, getrandom::Error> {
|
||||
let mut buf = [0u8; 16];
|
||||
fill(&mut buf)?;
|
||||
Ok(encode(&buf))
|
||||
}
|
||||
|
||||
fn generate_refresh_token() -> Result<String, getrandom::Error> {
|
||||
let mut buf = [0u8; 32];
|
||||
fill(&mut buf)?;
|
||||
Ok(encode(&buf))
|
||||
}
|
|
@ -6,6 +6,7 @@ use std::time::SystemTime;
|
|||
mod config;
|
||||
use config::{Config, ConfigBuilder};
|
||||
mod api;
|
||||
mod crypto;
|
||||
|
||||
type Error = Box<dyn std::error::Error>;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue