Logo

Programming-Idioms

This language bar is your friend. Select your favorite languages!

Idiom #234 Encode bytes to base64

Assign to the string s the standard base64 encoding of the byte array data, as specified by RFC 4648.

import base64
b = base64.b64encode(data)
s = b.decode()

b is a bytes object
s is a unicode string
using System;
string s = Convert.ToBase64String(data);

New implementation...
< >
programming-idioms.org