$ErrorActionPreference = "Stop"
$dir = "$env:USERPROFILE\Desktop\LR4"
$archive = "$dir\LR4_transport_AES256.zip"
$password = "LR4-Transfer!26"
$sevenZip = @(
"$env:ProgramFiles\7-Zip\7z.exe",
"${env:ProgramFiles(x86)}\7-Zip\7z.exe"
) | Where-Object { Test-Path $_ } | Select-Object -First 1
if (-not $sevenZip) {
throw "7-Zip not found"
}
# Exact file names
$files = @(
"$dir\LR4_Word.docx",
"$dir\LR4_Excel.xlsx",
"$dir\LR4.pdf"
)
# Check files
foreach ($file in $files) {
if (-not (Test-Path $file)) {
throw "File not found: $file"
}
Write-Host "FOUND: $file" -ForegroundColor Green
}
# Remove previous archive if present
if (Test-Path $archive) {
Remove-Item $archive -Force
}
# Create AES-256 ZIP
& $sevenZip a -tzip -mem=AES256 "-p$password" -y `
$archive $files
if ($LASTEXITCODE -ne 0) {
throw "Archive creation failed"
}
# Verify encrypted archive
& $sevenZip t "-p$password" $archive | Out-Null
if ($LASTEXITCODE -ne 0) {
throw "Archive verification failed"
}
Write-Host ""
Write-Host "SUCCESS! AES-256 archive created" -ForegroundColor Green
Write-Host "File: $archive"
Write-Host "Password: $password"
explorer.exe $dir