Copied from https://nachtimwald.com/2017/11/18/base64-encode-and-decode-in-c/.