Octal escapes
Octal escapes
Encode a string as three-digit octal escapes
Each byte is converted to a backslash followed by three octal digits:
value = "test"
octal_value = ""
for byte in value.encode():
octal_value += f"\\{byte:03o}"\164\145\163\164.encode() converts the string to bytes. Iterating over the result provides each byte as an integer. The o format converts that integer to octal, while 03 pads it to three digits. The doubled backslash produces one literal backslash in octal_value.
Find by: python, octal, octal encoding, octal escape, three digit octal, byte encoding, format specifier, 03o, backslash escape · Source: HTB/pcalc