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
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))
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue