fix: encrypt_type not set

This commit is contained in:
b1n
2024-06-24 01:09:32 +08:00
parent 442f4fac8c
commit 6f1a0fd0d0
2 changed files with 4 additions and 4 deletions

View File

@@ -687,6 +687,7 @@ impl Application for Pumpbin {
self.supported_platforms = platforms; self.supported_platforms = platforms;
// random pass // random pass
self.encrypt_type = plugin.encrypt_type().clone();
self.random_encrypt_pass(); self.random_encrypt_pass();
Task::none() Task::none()

View File

@@ -1,6 +1,6 @@
use std::{collections::HashMap, fmt::Display, fs, ops::Not, path::Path}; use std::{collections::HashMap, fmt::Display, fs, ops::Not, path::Path};
use aes_gcm::{aead::Aead, Aes256Gcm, KeyInit, Nonce}; use aes_gcm::{aead::Aead, Aes256Gcm, Key, KeyInit, Nonce};
use anyhow::anyhow; use anyhow::anyhow;
use bincode::{decode_from_slice, encode_to_vec, Decode, Encode}; use bincode::{decode_from_slice, encode_to_vec, Decode, Encode};
use dirs::data_dir; use dirs::data_dir;
@@ -77,11 +77,10 @@ impl EncryptType {
.map(|(i, byte)| byte ^ x[i % x.len()]) .map(|(i, byte)| byte ^ x[i % x.len()])
.collect()), .collect()),
EncryptType::AesGcm(x) => { EncryptType::AesGcm(x) => {
let key = aes_gcm::Key::<Aes256Gcm>::from_slice(x.key_holder()); let key = Key::<Aes256Gcm>::from_slice(x.key_holder());
let aes = Aes256Gcm::new(key); let aes = Aes256Gcm::new(key);
let nonce = Nonce::from_slice(x.nonce_holder()); let nonce = Nonce::from_slice(x.nonce_holder());
aes.encrypt(nonce, data.as_slice()) aes.encrypt(nonce, data.as_slice()).map_err(|e| anyhow!(e))
.map_err(|e| anyhow!(e.to_string()))
} }
} }
} }