package renjie120;
import java.io.UnsupportedEncodingException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class MyBase64 {
public MyBase64() {
}
static int w;// 3-编码时数组除以3余下的数
static char[] source;
static String Base64Code = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
static char[] baseCodes = Base64Code.toCharArray();
static String regex = "^[ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=]*$";
public static char[] ToBase64String(char[] input) {
source = input;
int messageLen = input.length;
int page = messageLen / 3;
int messageLen2;
if ((messageLen % 3) > 0) {
page++;
w = 3 - messageLen % 3;
}
messageLen2 = messageLen + w;
char[] before = new char[messageLen2];
for (int x = 0; x
if (x
before[x] = source[x];
} else {//将补上的数组设置为0
before[x] = 0;
}
}
char[] instr = new char[3];
char[] result = new char[page * 4];</