feat: v0.5.3, fix compress issue, supports env TINY_ENCRYPT_DEFAULT_ALGORITHM

This commit is contained in:
2023-10-25 23:16:20 +08:00
parent d5cb25cc6a
commit c05cf1a7cf
9 changed files with 65 additions and 28 deletions

16
src/util_env.rs Normal file
View File

@@ -0,0 +1,16 @@
use std::env;
use crate::consts;
pub fn get_default_encryption_algorithm() -> Option<&'static str> {
let env_default_algorithm = env::var(consts::TINY_ENCRYPT_ENV_DEFAULT_ALGORITHM).ok();
if let Some(env_algorithm) = env_default_algorithm {
let lower_default_algorithm = env_algorithm.to_lowercase();
match lower_default_algorithm.as_str() {
"aes" | "aes/gcm" => return Some(consts::TINY_ENC_AES_GCM),
"chacha20" | "chacha20/poly1305" => return Some(consts::TINY_ENC_CHACHA20_POLY1305),
_ => {}
}
}
None
}