From 888dab0e06cbf9a9976669dd4baf548a088c54f3 Mon Sep 17 00:00:00 2001 From: Timo <60073321+FrissBrot@users.noreply.github.com> Date: Tue, 22 Apr 2025 15:22:52 +0200 Subject: [PATCH] Create generate-key.ps1 --- arduino/generate-key.ps1 | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 arduino/generate-key.ps1 diff --git a/arduino/generate-key.ps1 b/arduino/generate-key.ps1 new file mode 100644 index 0000000..f927012 --- /dev/null +++ b/arduino/generate-key.ps1 @@ -0,0 +1,25 @@ +# AES-128: 16 Byte Key +$keyBytes = New-Object byte[] 16 +[System.Security.Cryptography.RandomNumberGenerator]::Create().GetBytes($keyBytes) + +# ───── Arduino Format ───── +$arduinoFormat = ( $keyBytes | ForEach-Object { "0x{0:X2}" -f $_ } ) -join ", " +$arduinoLine = "byte aes_key[] = { $arduinoFormat };" + +# ───── Python Format ───── +$pythonFormat = ( $keyBytes | ForEach-Object { "\x{0:X2}" -f $_ } ) -join "" +$pythonLine = "aes_key = b'" + $pythonFormat + "'" + +# ───── Klartext-Hex (ohne 0x oder \x) ───── +$hexPlain = ($keyBytes | ForEach-Object { "{0:X2}" -f $_ }) -join "" +$plainLine = "Plain Hex: " + $hexPlain + +# ───── Ausgabe ───── +Write-Host "🔐 AES-128 Schlüssel für Arduino:" +Write-Host $arduinoLine +Write-Host "" +Write-Host "🐍 AES-128 Schlüssel für Python:" +Write-Host $pythonLine +Write-Host "" +Write-Host "🧾 AES-128 Schlüssel im Klartext (Hex):" +Write-Host $plainLine