fix: PackedByteArray cannot be const in GDScript — move key halves inline

Generated with [Claude Code](https://claude.ai/code)
via [Happy](https://happy.engineering)

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Happy <yesreply@happy.engineering>
This commit is contained in:
dingo
2026-03-02 07:15:30 -05:00
co-authored by Claude Happy
parent 3c4908eec6
commit 8da0172563
@@ -32,16 +32,6 @@ extends Control
const _CREDS_PATH := "user://creds.dat"
# Key halves — XOR'd together at runtime so the plaintext key is never a
# contiguous literal in the binary. Both halves must be exactly 16 bytes.
const _KEY_A := PackedByteArray([
0x7A, 0x4D, 0x9F, 0x2C, 0xB8, 0x61, 0xE3, 0x5A,
0x0F, 0xC7, 0x94, 0x3B, 0xD6, 0x2E, 0x81, 0xF5,
])
const _KEY_B := PackedByteArray([
0x4C, 0xA9, 0x73, 0x1E, 0x5B, 0xD8, 0x06, 0x92,
0xE7, 0x3F, 0xC4, 0x6A, 0x17, 0x85, 0xB0, 0x2D,
])
# ── State ─────────────────────────────────────────────────────────────────────
@@ -174,11 +164,21 @@ func _friendly_error(code: String, message: String) -> String:
# ── Credential storage (AES-256-CBC) ─────────────────────────────────────────
func _build_key() -> PackedByteArray:
# Key halves XOR'd at runtime so the plaintext key is never a contiguous
# literal in the binary.
var a := PackedByteArray([
0x7A, 0x4D, 0x9F, 0x2C, 0xB8, 0x61, 0xE3, 0x5A,
0x0F, 0xC7, 0x94, 0x3B, 0xD6, 0x2E, 0x81, 0xF5,
])
var b := PackedByteArray([
0x4C, 0xA9, 0x73, 0x1E, 0x5B, 0xD8, 0x06, 0x92,
0xE7, 0x3F, 0xC4, 0x6A, 0x17, 0x85, 0xB0, 0x2D,
])
var key := PackedByteArray()
key.resize(32)
for i in 16:
key[i] = _KEY_A[i] ^ (i * 0x11)
key[i + 16] = _KEY_B[i] ^ (i * 0x11)
key[i] = a[i] ^ (i * 0x11)
key[i + 16] = b[i] ^ (i * 0x11)
return key