mirror of
https://github.com/michivonah/bbzw-horizon.git
synced 2025-12-22 17:16:27 +01:00
Create generate-key.ps1
This commit is contained in:
parent
abcb230656
commit
888dab0e06
1 changed files with 25 additions and 0 deletions
25
arduino/generate-key.ps1
Normal file
25
arduino/generate-key.ps1
Normal file
|
|
@ -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
|
||||||
Loading…
Add table
Add a link
Reference in a new issue