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.

final s = data.encodeBase64().toString()
using System;
string s = Convert.ToBase64String(data);
import 'dart:convert';
var s = base64.encode(data);
import "encoding/base64"
s := base64.StdEncoding.EncodeToString(data)
let s = btoa(data);
import static java.util.Base64.getEncoder;
byte data[] = s.getBytes();
String s = getEncoder().encodeToString(data);
uses base64;
s := EncodeStringBase64(data);
use MIME::Base64;
$encoded = encode_base64('Aladdin:open sesame');
$decoded = decode_base64($encoded);
import base64
b = base64.b64encode(data)
s = b.decode()
require 'base64'
s = Base64.strict_encode64(data)
let s = base64::encode(data);
(require net/base64)
(base64-encode
 (list->bytes
  (map char->integer
       (string->list "hi there"))))
Imports System
Dim s As String = Convert.ToBase64String(data)

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