mirror of
https://github.com/yuezk/GlobalProtect-openconnect.git
synced 2025-05-20 07:26:58 -04:00
Refactor using Tauri (#278)
This commit is contained in:
21
crates/gpapi/src/utils/base64.rs
Normal file
21
crates/gpapi/src/utils/base64.rs
Normal file
@@ -0,0 +1,21 @@
|
||||
use base64::{engine::general_purpose, Engine};
|
||||
|
||||
pub fn encode(data: &[u8]) -> String {
|
||||
let engine = general_purpose::STANDARD;
|
||||
|
||||
engine.encode(data)
|
||||
}
|
||||
|
||||
pub fn decode_to_vec(s: &str) -> anyhow::Result<Vec<u8>> {
|
||||
let engine = general_purpose::STANDARD;
|
||||
let decoded = engine.decode(s)?;
|
||||
|
||||
Ok(decoded)
|
||||
}
|
||||
|
||||
pub(crate) fn decode_to_string(s: &str) -> anyhow::Result<String> {
|
||||
let decoded = decode_to_vec(s)?;
|
||||
let decoded = String::from_utf8(decoded)?;
|
||||
|
||||
Ok(decoded)
|
||||
}
|
Reference in New Issue
Block a user