PowerShell: update to Embed Audio file

Trying to get that the data stream is on one line vs hundreds of lines.
The change was in the Convert to Base64 block. I found that I needed to add some additional parameters:
[Convert]::ToBase64String($encrypted, [Base64FormattingOptions]::None)
This will output the data stream to a one line, and even if output to a text file, now I don’t have to scroll through several hundreds lines of code just to get to what I need.
Add-Type -AssemblyName System.IO.Compression.FileSystem
# --- Input WAV file path ---
$inputFile = "Location to file\batman_theme_x.wav"
# --- AES Key & IV (must match your playback script) ---
$key = [Text.Encoding]::UTF8.GetBytes("1234567890123456")
$iv = [Text.Encoding]::UTF8.GetBytes("6543210987654321")
# --- Read WAV file bytes ---
$bytes = [IO.File]::ReadAllBytes($inputFile)
# --- Compress with GZip ---
$ms = New-Object System.IO.MemoryStream
$gzip = New-Object System.IO.Compression.GZipStream($ms, [System.IO.Compression.CompressionMode]::Compress)
$gzip.Write($bytes, 0, $bytes.Length)
$gzip.Close()
$compressed = $ms.ToArray()
# --- Encrypt with AES ---
$aes = [System.Security.Cryptography.Aes]::Create()
$aes.Key = $key
$aes.IV = $iv
$encryptor = $aes.CreateEncryptor()
$ms2 = New-Object System.IO.MemoryStream
$cs = New-Object System.Security.Cryptography.CryptoStream($ms2, $encryptor, [System.Security.Cryptography.CryptoStreamMode]::Write)
$cs.Write($compressed, 0, $compressed.Length)
$cs.Close()
$encrypted = $ms2.ToArray()
# --- Convert to Base64 ---
#$base64 = [Convert]::ToBase64String($encrypted)
$base64 = [Convert]::ToBase64String($encrypted, [Base64FormattingOptions]::None)
# --- Output result ---
"-----BEGIN AUDIO DATA-----"
$base64
"-----END AUDIO DATA-----"
#[Convert]::ToBase64String($encrypted,[Base64FormattingOptions]::None) | Out-File "audio.b64" -NoNewline
I hope this helps, as it did for me. Still learning as I go.
Make sure to changes the keys
AES Key & IV (must match your playback script)