Microsoft Interview Question

Q: How would you write this encryption function?