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

com.fengwenyi.javalib.encryption.Base64Utils Maven / Gradle / Ivy

There is a newer version: 3.0.1
Show newest version
package com.fengwenyi.javalib.encryption;

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

/**
 * Base64加解密工具
 * @author Erwin Feng
 * @since 2021-09-15
 */
public class Base64Utils {

    /**
     * 加密
     * @param src 待加密的字节数组
     * @return 加密串
     */
    public static String encrypt(byte[] src) {
        return Base64.getEncoder().encodeToString(src);
    }

    /**
     * 解密
     * @param src 加密字符串
     * @return 字节数组
     */
    public static byte[] decode(String src) {
        return Base64.getDecoder().decode(src.getBytes(StandardCharsets.UTF_8));
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy