package net.ranides.assira.text;

import lombok.experimental.UtilityClass;

import java.util.Base64;

/**
 * Basic base64 methods built on top of {@link Base64}
 */
@UtilityClass
public class FormatBase64 {

    /**
     * Encodes binary data to String using basic scheme (no line separators)
     *
     * @param data data
     * @return data
     */
    public static String format(byte[] data) {
        return Base64.getEncoder().encodeToString(data);
    }

    /**
     * Decodes string using basic base64 scheme into binary data
     *
     * @param data data
     * @return data
     */
    public static byte[] parse(String data) {
        return Base64.getDecoder().decode(data);
    }

}
