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

com.baomidou.kisso.common.util.Base64Util Maven / Gradle / Ivy

There is a newer version: 3.9.1
Show newest version
/*
 * Copyright (c) 2011-2020, hubin ([email protected]).
 * 

* Licensed under the Apache License, Version 2.0 (the "License"); you may not * use this file except in compliance with the License. You may obtain a copy of * the License at *

* http://www.apache.org/licenses/LICENSE-2.0 *

* Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the * License for the specific language governing permissions and limitations under * the License. */ package com.baomidou.kisso.common.util; import com.baomidou.kisso.SSOConfig; import com.baomidou.kisso.common.encrypt.base64.Base64; import com.baomidou.kisso.common.encrypt.base64.UrlBase64; /** *

* BASE64编码解码工具包 *

*

* 依赖bcprov-jdk14-1.48.jar *

* * @author hubin * @since 2014-6-17 */ public class Base64Util { /** *

* BASE64字符串解码为二进制数据 *

* * @param base64 * @return * @throws Exception */ public static byte[] decode(String base64) { return Base64.decode(base64.getBytes()); } /** *

* 二进制数据编码为BASE64字符串 *

* * @param bytes * @return * @throws Exception */ public static String encode(byte[] bytes) { return new String(Base64.encode(bytes)); } /** * BASE64 encrypt * * @param key * @return * @throws Exception */ public static String encryptBASE64(byte[] key) throws Exception { byte[] b = UrlBase64.encode(key); return new String(b, SSOConfig.getSSOEncoding()); } /** * BASE64 decrypt * * @param key * @return * @throws Exception */ public static byte[] decryptBASE64(String key) throws Exception { return UrlBase64.decode(key.getBytes(SSOConfig.getSSOEncoding())); } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy