perf(sandbox): optimize code encryption handling

This commit is contained in:
Eternity
2026-01-26 12:22:54 +08:00
parent 0fd8a122fb
commit 1fc04c37d3
2 changed files with 3 additions and 2 deletions

View File

@@ -12,9 +12,10 @@ def encrypt_code(code: bytes, key: bytes) -> str:
Returns:
Base64 encoded encrypted code
"""
key_length = len(key)
encrypted_code = bytearray(len(code))
for i in range(len(code)):
encrypted_code[i] = code[i] ^ key[i % 64]
encrypted_code[i] = code[i] ^ key[i % key_length]
encoded_code = base64.b64encode(encrypted_code).decode("utf-8")
return encoded_code

View File

@@ -17,7 +17,7 @@ sys.excepthook = excepthook
# Load security library if available
lib = ctypes.CDLL("./libpython.so")
lib.init_seccomp.argtypes = [ctypes.c_uint32, ctypes.c_uint32, ctypes.c_bool]
lib.init_seccomp.restype = None
lib.init_seccomp.restype = None # TODO: raise error info
# Get running path
running_path = sys.argv[1]