Logo

Programming-Idioms

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

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 static java.util.Base64.getEncoder;
byte data[] = s.getBytes();
String s = getEncoder().encodeToString(data);
using System;
string s = Convert.ToBase64String(data);

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