keygen to crypto module & fixed CI branch naming
This commit is contained in:
parent
f1bb0049da
commit
66dec81364
4
.github/workflows/ci.yml
vendored
4
.github/workflows/ci.yml
vendored
@ -2,9 +2,9 @@ name: Cargo Build & Test
|
|||||||
|
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: ["main"]
|
branches: ["master"]
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: ["main"]
|
branches: ["master"]
|
||||||
|
|
||||||
env:
|
env:
|
||||||
CARGO_TERM_COLOR: always
|
CARGO_TERM_COLOR: always
|
||||||
|
@ -4,6 +4,7 @@ use aes_gcm::{
|
|||||||
aes::Aes256,
|
aes::Aes256,
|
||||||
Aes256Gcm, AesGcm, KeyInit, Nonce,
|
Aes256Gcm, AesGcm, KeyInit, Nonce,
|
||||||
};
|
};
|
||||||
|
use rand::{distributions::Alphanumeric, Rng};
|
||||||
use rand::{rngs::OsRng, RngCore};
|
use rand::{rngs::OsRng, RngCore};
|
||||||
use std::{error::Error, path::Path};
|
use std::{error::Error, path::Path};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
@ -87,6 +88,14 @@ pub fn try_hash(path: &String) -> Result<String, Box<dyn Error + Send + Sync>> {
|
|||||||
Ok(hash)
|
Ok(hash)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn keygen() -> String {
|
||||||
|
rand::thread_rng()
|
||||||
|
.sample_iter(&Alphanumeric)
|
||||||
|
.take(8)
|
||||||
|
.map(char::from)
|
||||||
|
.collect::<String>()
|
||||||
|
}
|
||||||
|
|
||||||
#[cfg(test)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
use super::*;
|
use super::*;
|
||||||
|
@ -2,7 +2,6 @@ use crate::{
|
|||||||
common::{Connection, Message},
|
common::{Connection, Message},
|
||||||
comms, crypto,
|
comms, crypto,
|
||||||
};
|
};
|
||||||
use rand::{distributions::Alphanumeric, Rng};
|
|
||||||
use std::{collections::HashMap, error::Error, net::SocketAddr, path::PathBuf, str::FromStr};
|
use std::{collections::HashMap, error::Error, net::SocketAddr, path::PathBuf, str::FromStr};
|
||||||
use tokio::{
|
use tokio::{
|
||||||
fs::File,
|
fs::File,
|
||||||
@ -218,11 +217,3 @@ impl Listener {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn keygen() -> String {
|
|
||||||
rand::thread_rng()
|
|
||||||
.sample_iter(&Alphanumeric)
|
|
||||||
.take(8)
|
|
||||||
.map(char::from)
|
|
||||||
.collect::<String>()
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user