Functional Base64 encoding! Definitely needs refactoring, but it's not so bad.