Base 64 encoding with Scala or Java

Since Java 8 there are handy utility classes directly in the standard library: Base64.Decoder and Base64.Encoder. There are also some static factory methods to construct instances of these classes which perform Base64 encoding/decoding for various flavors of Base64 in Base64 class.

This is how to use the encoder:

import java.util.Base64
import java.nio.charset.StandardCharsets

Base64.getEncoder.encodeToString("user:pass".getBytes(StandardCharsets.UTF_8))

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)