Pregunta de entrevista de Microsoft

Q: How would you write this encryption function?