Work on passcodes and encryption
This commit is contained in:
@@ -91,16 +91,10 @@ export let split_iv_and_base64 = function split_iv_and_base64(
|
||||
if (log_lvl) {
|
||||
console.log(`IV: ${iv}; Encrypted:`, base64);
|
||||
}
|
||||
|
||||
// const [ivBase64, base64] = combined.split(':');
|
||||
// const iv = Uint8Array.from(atob(ivBase64), c => c.charCodeAt(0));
|
||||
// if (log_lvl) {
|
||||
// console.log(`IV: ${iv}; Encrypted: ${base64}`);
|
||||
// }
|
||||
return { iv, base64 };
|
||||
}
|
||||
|
||||
// Updated 2025-05-08
|
||||
// Updated 2025-05-15
|
||||
export let decrypt_wrapper = async function decrypt_wrapper(
|
||||
combined: string,
|
||||
keyData: string
|
||||
@@ -110,11 +104,17 @@ export let decrypt_wrapper = async function decrypt_wrapper(
|
||||
return '';
|
||||
}
|
||||
const { iv, base64 } = split_iv_and_base64(combined);
|
||||
const decrypted = await decrypt_content(base64, iv, keyData);
|
||||
if (log_lvl > 1) {
|
||||
console.log(`IV: ${iv}; Decrypted:`, decrypted);
|
||||
} else if (log_lvl) {
|
||||
console.log(`IV: ${iv}`);
|
||||
let decrypted;
|
||||
try {
|
||||
decrypted = await decrypt_content(base64, iv, keyData);
|
||||
if (log_lvl > 1) {
|
||||
console.log(`IV: ${iv}; Decrypted:`, decrypted);
|
||||
} else if (log_lvl) {
|
||||
console.log(`IV: ${iv}`);
|
||||
}
|
||||
} catch (error) {
|
||||
console.error('Decryption failed:', error);
|
||||
return '';
|
||||
}
|
||||
return decrypted;
|
||||
}
|
||||
Reference in New Issue
Block a user