Update dependencies

This commit is contained in:
Ethan O'Brien
2026-05-02 15:59:40 -05:00
parent ad0009baf6
commit d017fc43bb
5 changed files with 389 additions and 519 deletions

View File

@@ -1,7 +1,6 @@
use base64::{Engine as _, engine::general_purpose};
use rand::RngExt;
use aes::cipher::BlockEncryptMut;
use aes::cipher::{block_padding::Pkcs7, BlockDecryptMut, KeyIvInit};
use aes::cipher::{block_padding::Pkcs7, BlockModeEncrypt, BlockModeDecrypt, KeyIvInit};
type Aes256CbcEnc = cbc::Encryptor<aes::Aes256>;
type Aes256CbcDec = cbc::Decryptor<aes::Aes256>;
@@ -18,8 +17,8 @@ pub fn decrypt_packet(base64_input: &str) -> Result<String, String> {
let decryption_iv = &base64_buffer[..IV_LENGTH];
let mut ciphertext = base64_buffer[IV_LENGTH..].to_vec();
let decrypted_data = Aes256CbcDec::new(KEY.as_bytes().into(), decryption_iv.into())
.decrypt_padded_mut::<Pkcs7>(&mut ciphertext).ok()
let decrypted_data = Aes256CbcDec::new(&KEY.as_bytes().try_into().unwrap(), decryption_iv.try_into().unwrap())
.decrypt_padded::<Pkcs7>(&mut ciphertext).ok()
.ok_or(String::from("uhoh"))?;
Ok(String::from_utf8(decrypted_data.to_vec()).unwrap())
@@ -28,8 +27,8 @@ pub fn decrypt_packet(base64_input: &str) -> Result<String, String> {
pub fn encrypt_packet(input: &str) -> Result<String, String> {
let encryption_iv = generate_random_iv();
let encrypted = Aes256CbcEnc::new(KEY.as_bytes().into(), encryption_iv.as_slice().into())
.encrypt_padded_vec_mut::<Pkcs7>(input.as_bytes());
let encrypted = Aes256CbcEnc::new(KEY.as_bytes().try_into().unwrap(), encryption_iv.as_slice().try_into().unwrap())
.encrypt_padded_vec::<Pkcs7>(input.as_bytes());
let mut result = encryption_iv.to_vec();
result.extend_from_slice(&encrypted);

View File

@@ -4,7 +4,7 @@ use std::collections::HashMap;
use sha1::Sha1;
use substring::Substring;
use jzon::{object, JsonValue};
use hmac::{Hmac, Mac};
use hmac::{Hmac, Mac, KeyInit};
use rusqlite::params;
use lazy_static::lazy_static;

View File

@@ -277,7 +277,7 @@ fn _a_sha1(t: &str) -> String {
let mut hasher = Sha1::new();
hasher.update(t.as_bytes());
let result = hasher.finalize();
format!("{:X}", result)
hex::encode_upper(result)
}
fn generate_passcode_sha1(transfer_id: String, transfer_code: String) -> String {