src/main/java/at/favre/tools/dice/encode/impl/Base58.java
public String encode(byte[] input) {
        if (input.length == 0) {
            return "";
        }
        // Count leading zeros.
        int zeros = 0;
        while (zeros < input.length && input[zeros] == 0) {
            ++zeros;
        }
        // Convert base-256 digits to base-58 digits (plus conversion to ASCII characters)
        input = Arrays.copyOf(input, input.length); // since we modify it in-place
        char[] encoded = new char[input.length * 2]; // upper bound
        int outputStart = encoded.length;
        for (int inputStart = zeros; inputStart < input.length; ) {
            encoded[--outputStart] = alphabet[divmod(input, inputStart, 256, 58)];
            if (input[inputStart] == 0) {
                ++inputStart; // optimization - skip leading zeros
            }
        }
        // Preserve exactly as many leading encoded zeros in output as there were leading zeros in input.
        while (outputStart < encoded.length && encoded[outputStart] == encodedZero) {
            ++outputStart;
        }
        while (--zeros >= 0) {
            encoded[--outputStart] = encodedZero;
        }
        // Return encoded string (including encoded leading zeros).
        return new String(encoded, outputStart, encoded.length - outputStart);
    }
/**
     * Encodes the given bytes as a base58 string (no checksum is appended).
     *
     * @param input the bytes to encode
     * @return the base58-encoded string
     */
Encodes the given bytes as a base58 string (no checksum is appended).
@param input the bytes to encode
@return the base58-encoded string
Encodes the given bytes as a base58 string ( no checksum is appended ) . @param input the bytes to encode @return the base58 - encoded string
public String encode(byte[] input) {
        if (input.length == 0) {
            return "";
        }
        int zeros = 0;
        while (zeros < input.length && input[zeros] == 0) {
            ++zeros;
        }
        input = Arrays.copyOf(input, input.length); 
        char[] encoded = new char[input.length * 2]; 
        int outputStart = encoded.length;
        for (int inputStart = zeros; inputStart < input.length; ) {
            encoded[--outputStart] = alphabet[divmod(input, inputStart, 256, 58)];
            if (input[inputStart] == 0) {
                ++inputStart; 
            }
        }
        while (outputStart < encoded.length && encoded[outputStart] == encodedZero) {
            ++outputStart;
        }
        while (--zeros >= 0) {
            encoded[--outputStart] = encodedZero;
        }
        return new String(encoded, outputStart, encoded.length - outputStart);
    }
public String encode ( byte [ ] input ) { if ( input . length == 0 ) { return "" ; } int zeros = 0 ; while ( zeros < input . length && input [ zeros ] == 0 ) { ++ zeros ; } input = Arrays . copyOf ( input , input . length ) ; char [ ] encoded = new char [ input . length * 2 ] ; int outputStart = encoded . length ; for ( int inputStart = zeros ; inputStart < input . length ; ) { encoded [ -- outputStart ] = alphabet [ divmod ( input , inputStart , 256 , 58 ) ] ; if ( input [ inputStart ] == 0 ) { ++ inputStart ; } } while ( outputStart < encoded . length && encoded [ outputStart ] == encodedZero ) { ++ outputStart ; } while ( -- zeros >= 0 ) { encoded [ -- outputStart ] = encodedZero ; } return new String ( encoded , outputStart , encoded . length - outputStart ) ; }
Encodes the given bytes as a base58 string (no checksum is appended).
Encodes the given bytes as a base58 string ( no checksum is appended ) .
// Count leading zeros. // Convert base-256 digits to base-58 digits (plus conversion to ASCII characters) // since we modify it in-place // upper bound // optimization - skip leading zeros // Preserve exactly as many leading encoded zeros in output as there were leading zeros in input. // Return encoded string (including encoded leading zeros).