public static String encode(byte[] raw) {
		if (raw == null) {
			return "";
		}

		StringBuilder buffer = new StringBuilder((1 + (raw.length / 3)) * 3);
		int tracker = 0;
		while (tracker + 3 <= raw.length) {
			buffer.append(MAPPING[(raw[tracker] & 0xff) >> 2])
					.append(MAPPING[((raw[tracker] & 0x03) << 4)
							| (raw[tracker + 1] & 0xf0) >> 4]) //
					.append(MAPPING[((raw[tracker + 1] & 0x0f) << 2)
							| ((raw[tracker + 2]) & 0xc0) >> 6])//
					.append(MAPPING[raw[tracker + 2] & 0x3f]);
			tracker += 3;
		}

		if (tracker < raw.length) {
			switch (raw.length - tracker) {
			case 1:
				buffer.append(MAPPING[(raw[tracker] & 0xff) >> 2]) //
						.append(MAPPING[((raw[tracker] & 0x03) << 4)]) //
						.append('=').append('=');
				break;
			case 2:
				buffer.append(MAPPING[(raw[tracker] & 0xff) >> 2])
						.append(MAPPING[((raw[tracker] & 0x3) << 4)
								| (raw[tracker + 1] & 0xf0) >> 4]) //
						.append(MAPPING[((raw[tracker + 1] & 0xf) << 2)]) //
						.append('=');
				break;
			default:
				throw new RuntimeException(
						"unexpected base64 enconde,should not here");
			}
		}

		return buffer.toString();
	}