public static String encodeToString(byte[] bytes) {
        if (bytes == null || bytes.length == 0) return null;

        StringBuilder buf = new StringBuilder();

        int length = bytes.length;
        int remainder = length % 3;
        int i = 0; //starting byte
        int last3ByteIndex = length - remainder; //last byte whose index is a multiple of 3

        for(; i < last3ByteIndex; i += 3) {
            int twentyFourBit = toInt(bytes, i, 3);
            encodeAndAppend(twentyFourBit, buf, 4);
        }
        if (remainder > 0) {
            //one or two bytes that we still need to encode:
            int a = toInt(bytes, i, remainder);
            encodeAndAppend(a, buf, remainder + 1);
        }
        return buf.toString();
    }
Encodes the specified bytes to an {@code H64}-encoded String.

@param bytes
@return
src/main/java/org/apache/shiro/lang/codec/H64.java