frontend changes

This commit is contained in:
2026-03-25 01:41:40 -06:00
parent b4bcb8f3f2
commit 00ee076baa
6 changed files with 12 additions and 18 deletions

View File

@ -1,5 +1,3 @@
use tauri::Manager;
// --- Commands ---
/// Returns the backend URL. Stubbed for now; will be replaced once the
@ -15,26 +13,23 @@ fn get_backend_url() -> String {
/// OS keychain implementation is added (e.g. tauri-plugin-stronghold).
#[tauri::command]
fn encrypt_string(data: String) -> String {
use std::io::Write;
let encoded = data
data
.as_bytes()
.iter()
.fold(String::new(), |mut acc, b| {
use std::fmt::Write as FmtWrite;
let _ = write!(acc, "{:02x}", b);
acc
});
encoded
})
}
/// Companion decode for encrypt_string.
#[tauri::command]
fn decrypt_string(encrypted: String) -> Result<String, String> {
let bytes: Result<Vec<u8>, _> = (0..encrypted.len())
(0..encrypted.len())
.step_by(2)
.map(|i| u8::from_str_radix(&encrypted[i..i + 2], 16))
.collect();
bytes
.collect::<Result<Vec<u8>, _>>()
.map_err(|e| format!("decrypt error: {e}"))
.and_then(|b| String::from_utf8(b).map_err(|e| format!("utf8 error: {e}")))
}