Question d’entretien chez Microsoft

Q: How would you write this encryption function?