src/org/kocakosm/pitaya/util/BaseEncoding.java
public String encode(byte[] in, int off, int len)
	{
		checkBounds(in, off, len);
		StringBuilder sb = new StringBuilder(maxEncodedLength(len));
		int accu = 0;
		int count = 0;
		int b = alphabet.bitsPerChar();
		for (int i = off; i < off + len; i++) {
			accu = (accu << 8) | (in[i] & 0xFF);
			count += 8;
			while (count >= b) {
				count -= b;
				sb.append(alphabet.encode(accu >>> count));
			}
		}
		if (count > 0) {
			accu = (accu & (0xFF >>> (8 - count))) << (b - count);
			sb.append(alphabet.encode(accu));
			if (!omitPadding) {
				int c = alphabet.charsPerBlock();
				int pad = c - (sb.length() % c);
				for (int i = 0; i < pad; i++) {
					sb.append(PADDING_CHAR);
				}
			}
		}
		insertSeparators(sb);
		return sb.toString();
	}
public String encode(byte[] in, int off, int len)
	{
		checkBounds(in, off, len);
		StringBuilder sb = new StringBuilder(maxEncodedLength(len));
		int accu = 0;
		int count = 0;
		int b = alphabet.bitsPerChar();
		for (int i = off; i < off + len; i++) {
			accu = (accu << 8) | (in[i] & 0xFF);
			count += 8;
			while (count >= b) {
				count -= b;
				sb.append(alphabet.encode(accu >>> count));
			}
		}
		if (count > 0) {
			accu = (accu & (0xFF >>> (8 - count))) << (b - count);
			sb.append(alphabet.encode(accu));
			if (!omitPadding) {
				int c = alphabet.charsPerBlock();
				int pad = c - (sb.length() % c);
				for (int i = 0; i < pad; i++) {
					sb.append(PADDING_CHAR);
				}
			}
		}
		insertSeparators(sb);
		return sb.toString();
	}
public String encode ( byte [ ] in , int off , int len ) { checkBounds ( in , off , len ) ; StringBuilder sb = new StringBuilder ( maxEncodedLength ( len ) ) ; int accu = 0 ; int count = 0 ; int b = alphabet . bitsPerChar ( ) ; for ( int i = off ; i < off + len ; i ++ ) { accu = ( accu << 8 ) | ( in [ i ] & 0xFF ) ; count += 8 ; while ( count >= b ) { count -= b ; sb . append ( alphabet . encode ( accu >>> count ) ) ; } } if ( count > 0 ) { accu = ( accu & ( 0xFF >>> ( 8 - count ) ) ) << ( b - count ) ; sb . append ( alphabet . encode ( accu ) ) ; if ( ! omitPadding ) { int c = alphabet . charsPerBlock ( ) ; int pad = c - ( sb . length ( ) % c ) ; for ( int i = 0 ; i < pad ; i ++ ) { sb . append ( PADDING_CHAR ) ; } } } insertSeparators ( sb ) ; return sb . toString ( ) ; }
Encodes the given data bytes according to this {@code BaseEncoding}'s
configuration.

@param in the input buffer.
@param off the input offset.
@param len the number of bytes to encode.

@return the encoded {@code String}.

@throws NullPointerException if {@code in} is {@code null}.
@throws IndexOutOfBoundsException if {@code off} or {@code len} is
negative or if {@code off + len} is greater than {@code in}'s
length.
Encodes the given data bytes according to this { @code BaseEncoding } s configuration .