// retoor <retoor@molodetz.nl>
import "bytes" for Bytes
System.print("=== Bytes Module Demo ===\n")
System.print("--- fromList / toList ---")
var list = [72, 101, 108, 108, 111]
var str = Bytes.fromList(list)
System.print("fromList([72, 101, 108, 108, 111]) = %(str)")
System.print("toList(%(str)) = %(Bytes.toList(str))")
System.print("\n--- length ---")
System.print("length('Hello World') = %(Bytes.length("Hello World"))")
System.print("\n--- concat ---")
var a = "Hello"
var b = " World"
System.print("concat('%(a)', '%(b)') = %(Bytes.concat(a, b))")
System.print("\n--- slice ---")
var data = "Hello World"
System.print("slice('%(data)', 0, 5) = %(Bytes.slice(data, 0, 5))")
System.print("slice('%(data)', 6, 11) = %(Bytes.slice(data, 6, 11))")
System.print("\n--- xorMask ---")
var payload = Bytes.fromList([1, 2, 3, 4, 5, 6, 7, 8])
var mask = Bytes.fromList([0x12, 0x34, 0x56, 0x78])
var masked = Bytes.xorMask(payload, mask)
System.print("Original: %(Bytes.toList(payload))")
System.print("Mask: %(Bytes.toList(mask))")
System.print("XOR'd: %(Bytes.toList(masked))")
var unmasked = Bytes.xorMask(masked, mask)
System.print("Unmasked: %(Bytes.toList(unmasked))")
System.print("\n--- Binary data handling ---")
var binary = Bytes.fromList([0, 127, 128, 255])
System.print("Binary data length: %(Bytes.length(binary))")
System.print("Binary data bytes: %(Bytes.toList(binary))")