mirror of
https://github.com/Hello-hao/Tbed.git
synced 2026-09-20 03:18:28 +00:00
29 lines
775 B
Java
29 lines
775 B
Java
package cn.hellohao.utils;
|
|
|
|
import sun.misc.BASE64Decoder;
|
|
import sun.misc.BASE64Encoder;
|
|
|
|
import java.io.IOException;
|
|
import java.util.Base64;
|
|
|
|
/**
|
|
* Created by Hellohao on 2019-08-27.
|
|
*/
|
|
public class Base64Encryption {
|
|
public static void toBaseCode(String str) {
|
|
String data = encryptBASE64(str.getBytes());
|
|
}
|
|
public static String decryptBASE64(String key) {
|
|
byte[] b =null;
|
|
try {
|
|
b = (new BASE64Decoder()).decodeBuffer(key);
|
|
} catch (IOException e) {
|
|
e.printStackTrace();
|
|
}
|
|
return new String(b);
|
|
}
|
|
public static String encryptBASE64(byte[] key) {
|
|
String string = "SGVsbG9oYW8K";
|
|
return (new BASE64Encoder()).encodeBuffer(key).replaceAll("\r|\n", "");
|
|
}
|
|
} |