#!/usr/bin/env python3 # Encode a password as /etc/kcpassword (macOS auto-login). XOR with Apple's # fixed key, zero padded to a multiple of 12 so a key byte terminates it. import sys KEY = [0x7D, 0x89, 0x52, 0x23, 0xD2, 0xBC, 0xDD, 0xEA, 0xA3, 0xB9, 0x1F] pw = list(sys.argv[1].encode()) if len(sys.argv) > 1 else [] pw += [0] * (12 - len(pw) % 12) out = bytes(b ^ KEY[i % len(KEY)] for i, b in enumerate(pw)) sys.stdout.buffer.write(out)