org.apache.commons.codec.binary.Base64


下载地址:http://commons.apache.org/proper/commons-codec/download_codec.cgi

链接:https://pan.baidu.com/s/1u2rJLGr-djqtO6aACCUIFQ
提取码:qun6

链接:https://pan.baidu.com/s/10YZClBY7uGfiBOXu3BD3lQ
提取码:5uyt

 

import org.apache.commons.codec.binary.Base64;

public class JdkBase64 {

public static void main(String[] args) {
String key = "这是需要加密的文字";
key = encode(key);
System.out.println(key);
key = decode(key);
System.out.println(key);
}

/**
* Base64加密
* @param key
* @return
*/
public static String encode(String key){
byte[] bt = key.getBytes();
return (new Base64().encodeToString(bt));
}

/**
* Baes64解密
* @param key
* @return
*/
private static String decode(String key){
byte[] bt = new Base64().decode(key);
return new String(bt);
}

}


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM