<?php
// Benötigte Variablen
$iv = str_repeat("\x00", 16); // 16 Bytes Null-Initialisierungsvektor $key = str_repeat("\x00", 16); // 16 Bytes Null-Schlüssel $picc = "CACDEC6C5455EE52BB1DA40470963113"; // Eingabewert
// 112233445566778899
// AES-Entschlüsselung im CBC-Modus
$encrypted_data = hex2bin($picc); // Konvertiert den Hex-String in Binärdaten
$decrypted_data = openssl_decrypt($encrypted_data, 'aes-128-cbc', $key, OPENSSL_RAW_DATA, $iv);
// Extrahieren des Zählerwerts
$byte9 = ord($picc[9]); // 10. Byte (Index 9) $byte8 = ord($picc[8]); // 9. Byte (Index 8) $counter = ($byte9 << 8) | $byte8; // Zusammenfügen der Bytes (Big-Endian)
echo "$decrypted_data\n";
echo "$picc\n";
echo "Counter: $counter\n";
?>
PD9waHAKLy8gQmVuw7Z0aWd0ZSBWYXJpYWJsZW4KJGl2ID0gc3RyX3JlcGVhdCgiXHgwMCIsIDE2KTsgLy8gMTYgQnl0ZXMgTnVsbC1Jbml0aWFsaXNpZXJ1bmdzdmVrdG9yCiRrZXkgPSBzdHJfcmVwZWF0KCJceDAwIiwgMTYpOyAvLyAxNiBCeXRlcyBOdWxsLVNjaGzDvHNzZWwKJHBpY2MgPSAiQ0FDREVDNkM1NDU1RUU1MkJCMURBNDA0NzA5NjMxMTMiOyAvLyBFaW5nYWJld2VydAovLyAgICAgICAxMTIyMzM0NDU1NjY3Nzg4OTkKLy8gQUVTLUVudHNjaGzDvHNzZWx1bmcgaW0gQ0JDLU1vZHVzCiRlbmNyeXB0ZWRfZGF0YSA9IGhleDJiaW4oJHBpY2MpOyAvLyBLb252ZXJ0aWVydCBkZW4gSGV4LVN0cmluZyBpbiBCaW7DpHJkYXRlbgokZGVjcnlwdGVkX2RhdGEgPSBvcGVuc3NsX2RlY3J5cHQoJGVuY3J5cHRlZF9kYXRhLCAnYWVzLTEyOC1jYmMnLCAka2V5LCBPUEVOU1NMX1JBV19EQVRBLCAkaXYpOwoKCi8vIEV4dHJhaGllc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