All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cn.zhxu.bp.utils.Base64Utils Maven / Gradle / Ivy

The newest version!
package cn.zhxu.bp.utils;

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

public class Base64Utils {

    public static String encode(String str) {
        return new String(
                Base64.getEncoder().encode(str.getBytes(StandardCharsets.UTF_8)),
                StandardCharsets.UTF_8
        );
    }

    public static String decode(String str) {
        byte[] headerBytes = str.getBytes(StandardCharsets.UTF_8);
        byte[] jsonBytes = Base64.getDecoder().decode(headerBytes);
        return new String(jsonBytes, StandardCharsets.UTF_8);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy