It uses WebAssembly.instantiate to create a WebAssembly instance. Then, each encoded character is appending to result. We then receive the result.
After some googling, I realised that the bytes given as wasmBuffer is actually a WebAssembly payload which exports a function called encode. After using the wasm2wat tool, I get the following web assembly:
I asked chatGPT to convert this into Python and got the following encoding function:
defencode(data):for i inrange(len(data) -1):for j inrange(i, len(data) -1): data[j +1]= data[j]^ data[j +1]return data
The encoding function iterates i from from the 0 to n - 1, and for each i it iterates j from i to n - 1. For each j value, the element at index j + 1 is XOR'd with the element at index j. To decode this function we can do the XOR operations in the reverse order.
x ="571653080c6e350c6b0f01196d06436075756365"ct = [x[i:i+2]for i inrange(0, len(x), 2)] # create an array of hex stringsn =len(ct)for i inrange(0, n): ct[i]=int(ct[i], 16)# convert hex values to intsfor i inrange(n -2, -1, -1):for j inrange(n -2, i -1, -1): ct[j +1]^= ct[j]# decodefor i inrange(0, n): ct[i]=chr(ct[i])print(ct)# CDDC24{WASM_15_R34LY_C00L!!}