Crates.io | verse-session-id |
lib.rs | verse-session-id |
version | 1.0.1 |
source | src |
created_at | 2023-07-14 07:21:42.311935 |
updated_at | 2023-07-14 21:31:46.702649 |
description | Session ID for [@VerseEngine/verse-core](https://github.com/VerseEngine/verse-core) |
homepage | https://verseengine.cloud/ |
repository | https://github.com/VerseEngine/verse-session-id |
max_upload_size | |
id | 915897 |
size | 21,481 |
ID with signature/verification functions.
Used as session ID in @VerseEngine/verse-core.
use verse_session_id::*;
...
pub fn verify_string(session_id: &str, signature: &str, data: &str) -> bool {
let Ok(sid) = session_id.parse::<SessionId>() else {
return false;
};
let Ok(ss) = signature.parse::<SignatureSet>() else {
return false;
};
sid.verify(vec![data.as_bytes()], &ss).is_ok()
}
let id_pair = new_session_id_pair()?;
let session_id = id_pair.get_id();
// to string
let s = format!("{}", session_id);
pub fn sign_string(&self, data: &str) -> Result<String> {
let id_pair = ...;
Ok(id_pair
.sign(vec![data.as_bytes()])?
.to_string())
}