write all to encrypted file instead
This commit is contained in:
+8
-12
@@ -22,9 +22,8 @@ fn main() -> std::io::Result<()> {
|
||||
let fname = args.get(1).unwrap();
|
||||
let plaintext_bytes = read(fname).expect("Failed to read file");
|
||||
|
||||
// Create output files with consistent naming
|
||||
let mut encrypted_file = File::create("encrypted_Input.bin")?;
|
||||
let mut metadata_file = File::create("decryption_metadata.bin")?;
|
||||
// Create single output file
|
||||
let mut output_file = File::create("encrypted_dll.dll")?;
|
||||
|
||||
// Master password (in production, this should be securely provided)
|
||||
let master_password = "YourSecureMasterPassword123!"; // Change this!
|
||||
@@ -72,17 +71,14 @@ fn main() -> std::io::Result<()> {
|
||||
ciphertext.extend_from_slice(&block);
|
||||
}
|
||||
|
||||
// Write encrypted data
|
||||
encrypted_file.write_all(&ciphertext)?;
|
||||
|
||||
// Write metadata for external decryption
|
||||
metadata_file.write_all(&salt)?;
|
||||
metadata_file.write_all(&iv)?;
|
||||
metadata_file.write_all(&(ciphertext.len() as u32).to_le_bytes())?;
|
||||
// Write metadata first, then encrypted data
|
||||
output_file.write_all(&salt)?;
|
||||
output_file.write_all(&iv)?;
|
||||
output_file.write_all(&(ciphertext.len() as u32).to_le_bytes())?;
|
||||
output_file.write_all(&ciphertext)?;
|
||||
|
||||
println!("Encryption complete!");
|
||||
println!("Encrypted file: encrypted_Input.bin");
|
||||
println!("Metadata file: decryption_metadata.bin");
|
||||
println!("Encrypted DLL: encrypted_dll.dll");
|
||||
println!("Master password: {}", master_password);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user