Decodes the given base58 string into the original data bytes.

@param input the base58-encoded string to decode
@return the decoded data bytes
@throws AddressFormatException if the given string is not a valid base58 string
428023
public static byte[] decode(String input) throws AddressFormatException {
        if (input.length() == 0) {
            return new byte[0];
        }
        // Convert the base58-encoded ASCII chars to a base58 byte sequence (base58 digits).
        byte[] input58 = new byte[input.length()];
        for (int i = 0; i < input.length(); ++i) {
            char c = input.charAt(i);
            int digit = c < 128 ? INDEXES[c] : -1;
            if (digit < 0) {
                throw new AddressFormatException.InvalidCharacter(c, i);
            }
            input58[i] = (byte) digit;
        }
        // Count leading zeros.
        int zeros = 0;
        while (zeros < input58.length && input58[zeros] == 0) {
            ++zeros;
        }
        // Convert base-58 digits to base-256 digits.
        byte[] decoded = new byte[input.length()];
        int outputStart = decoded.length;
        for (int inputStart = zeros; inputStart < input58.length; ) {
            decoded[--outputStart] = divmod(input58, inputStart, 58, 256);
            if (input58[inputStart] == 0) {
                ++inputStart; // optimization - skip leading zeros
            }
        }
        // Ignore extra leading zeroes that were added during the calculation.
        while (outputStart < decoded.length && decoded[outputStart] == 0) {
            ++outputStart;
        }
        // Return decoded data (including original number of leading zeros).
        return Arrays.copyOfRange(decoded, outputStart - zeros, decoded.length);
    }
737561
public static byte[] decode(String in) {

		in = in.replaceAll("\\r|\\n","");
		if(in.length() % 4 != 0) {
			throw new IllegalArgumentException("The length of the input string must be a multiple of four.");
		}

		if(!in.matches("^[A-Za-z0-9+/]*[=]{0,3}$")) {
			throw new IllegalArgumentException("The argument contains illegal characters.");
		}

		byte[] out = new byte[(in.length()*3)/4];

		char[] input = in.toCharArray();

		int outi = 0;
		int b1, b2, b3, b4;
		for(int i = 0; i < input.length; i+=4) {
			b1 = map.get(input[i]) - 1;
			b2 = map.get(input[i+1]) - 1;
			b3 = map.get(input[i+2]) - 1;
			b4 = map.get(input[i+3]) - 1;
			out[outi++] = (byte)(b1 << 2 | b2 >>> 4);
			out[outi++] = (byte)((b2 & 0x0F) << 4 | b3 >>> 2);
			out[outi++] = (byte)((b3 & 0x03) << 6 | (b4 & 0x3F));
		}

		if(in.endsWith("=")) {
			byte[] trimmed = new byte[out.length - (in.length() - in.indexOf("="))];
			System.arraycopy(out, 0, trimmed, 0, trimmed.length);
			return trimmed;
		}

		return out;

	}
214699
public static byte[] addressStringToBytes(String hex) {
        final byte[] addr;
        try {
            addr = Hex.decode(hex);
        } catch (DecoderException addressIsNotValid) {
            return null;
        }

        if (isValidAddress(addr))
            return addr;
        return null;
    }
947929
private byte[] encode(byte[] input) throws EncoderException
    {
        if (encoder != null)
        {
            return encoder.encode(input);
        }
        else
        {
            return DEFAULT_CODER.encode(input);
        }
    }
1309979
@Override
    public int decode ( byte[] buffer, int bufferIndex ) throws SMBProtocolDecodingException {
        int len = super.decode(buffer, bufferIndex);
        if ( this.byteCount == 0 ) {
            // otherwise hasMore may not be correctly set
            readBytesWireFormat(buffer, len + bufferIndex);
        }
        nextElement();
        return len;
    }
891888
public static byte[] decodeBase64(String encodedData) {
		BufferedReader reader = new BufferedReader(new StringReader(encodedData));
		int length = encodedData.length();
		byte[] retval = new byte[length];
		int actualLength = 0;

		String line;
		try {
			while ((line = reader.readLine()) != null) {
				byte[] rawData = line.getBytes();


				int n = 0;
				for (int i = 0; i < rawData.length; i += 4) {
					n = (base64Chars.indexOf(rawData[i]) << 18) |
							(base64Chars.indexOf(rawData[i + 1]) << 12);

					retval[actualLength++] = (byte) ((n >>> 16) & 255);

					if (rawData[i + 2] != '=') {
						n |= (base64Chars.indexOf(rawData[i + 2]) << 6);
						retval[actualLength++] = (byte) ((n >>> 8) & 255);
					}
					if (rawData[i + 3] != '=') {
						n |= (base64Chars.indexOf(rawData[i + 3]));
						retval[actualLength++] = (byte) (n & 255);
					}
				}
			}
		}
		catch (IOException ioe) {
			throw new IllegalStateException("exception while reading input with message: " + ioe);
		}
		if (actualLength != length) {
			byte[] actualRetval = new byte[actualLength];
			System.arraycopy(retval, 0, actualRetval, 0, actualLength);
			return actualRetval;
		}
		return retval;
	}
1272210
@SuppressWarnings("StatementWithEmptyBody")
    public static String encode(final byte[] input) {
        ByteArrayInputStream in = new ByteArrayInputStream(input);
        StringBuilder sb = new StringBuilder();
        try {
            while (encodeChunk(sb, in)) {
                // do nothing
            }
        } catch (IOException ex) {
            throw new RuntimeException(ex);
        }

        return sb.toString();
    }
101416
public static byte[] decodeMultiple(final byte[] input) {

        if (input == null) {
            throw new NullPointerException("input");
        }

        final byte[] output = new byte[input.length >> 1]; // /2

        decodeMultiple(input, 0, output, 0, output.length);

        return output;
    }
77107
function (input) {
			var bi = BigInteger.fromByteArrayUnsigned(input);
			var chars = [];

			while (bi.compareTo(B58.base) >= 0) {
				var mod = bi.mod(B58.base);
				chars.unshift(B58.alphabet[mod.intValue()]);
				bi = bi.subtract(mod).divide(B58.base);
			}
			chars.unshift(B58.alphabet[bi.intValue()]);

			// Convert leading zeros too.
			for (var i = 0; i < input.length; i++) {
				if (input[i] == 0x00) {
					chars.unshift(B58.alphabet[0]);
				} else break;
			}

			return chars.join('');
		}
760039
public static function base64url_decode($input)
  {
    $remainder = strlen($input) % 4;
    if ($remainder) {
        $padlen = 4 - $remainder;
        $input .= str_repeat('=', $padlen);
    }

    return base64_decode(strtr($input, '-_', '+/'));
  }
653214
static public byte[] getBytes(String input) {

        if (null != input) {
            int length = input.length();
            byte[] output = new byte[length];
            for (int i = 0; i < length; i++) {
                output[i] = (byte) input.charAt(i);
            }
            return output;
        }
        return null;
    }
968532
public static String toStringUTF8(byte[] input)
    {
        if (input == null)
        {
            return null;
        }

        try
        {
            return new String(input, "UTF-8");
        }
        catch (UnsupportedEncodingException e)
        {
            // This won't happen.
            return null;
        }
    }
349850
@Override
    public int decode ( byte[] buffer, int bufferIndex ) throws SMBProtocolDecodingException {
        int start = this.headerStart = bufferIndex;

        bufferIndex += readHeaderWireFormat(buffer, bufferIndex);
        bufferIndex += readAndXWireFormat(buffer, bufferIndex);

        int len = bufferIndex - start;
        this.length = len;

        if ( isRetainPayload() ) {
            byte[] payload = new byte[len];
            System.arraycopy(buffer, 4, payload, 0, len);
            setRawPayload(payload);
        }

        if ( !verifySignature(buffer, 4, len) ) {
            throw new SMBProtocolDecodingException("Signature verification failed for " + this.getClass().getName());
        }
        return len;
    }
1162054
@SuppressWarnings("unchecked")
        public static <T> T decode(String base64) {
                //BASE64Decoder decoder = new BASE64Decoder();
                try {
                        //byte[]               b    = decoder.decodeBuffer(base64);
                		byte[]               b    = Base64.decode(base64);
                        ByteArrayInputStream bais = new ByteArrayInputStream(b);
                        ObjectInputStream    ois  = new ObjectInputStream(bais);
                        return (T)ois.readObject();
                } catch (IOException | ClassNotFoundException e) {
                        throw new RuntimeException(e);
                }
        }
209002
public static 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] == ENCODED_ZERO) {
            ++outputStart;
        }
        while (--zeros >= 0) {
            encoded[--outputStart] = ENCODED_ZERO;
        }
        // Return encoded string (including encoded leading zeros).
        return new String(encoded, outputStart, encoded.length - outputStart);
    }
276579
public static String md5Hex(final String input) {
		if (input == null) {
			throw new NullPointerException("String is null");
		}

    	MessageDigest digest = null;
    	
    	try {
    		digest = MessageDigest.getInstance("MD5");
    	} catch (NoSuchAlgorithmException e) {
    		// this should never happen
    		throw new RuntimeException(e);
    	}
        
        byte[] hash = digest.digest(input.getBytes());
        
        return DatatypeConverter.printHexBinary(hash);
    }
1302821
@Override
	public void read(final DataInput in) throws IOException {
		int len = in.readUnsignedByte();

		if (len >= HIGH_BIT) {
			int shift = 7;
			int curr;
			len = len & 0x7f;
			while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
				len |= (curr & 0x7f) << shift;
				shift += 7;
			}
			len |= curr << shift;
		}
		
		this.len = len;
		this.hashCode = 0;
		ensureSize(len);
		final char[] data = this.value;

		for (int i = 0; i < len; i++) {
			int c = in.readUnsignedByte();
			if (c < HIGH_BIT) {
				data[i] = (char) c;
			} else {
				int shift = 7;
				int curr;
				c = c & 0x7f;
				while ((curr = in.readUnsignedByte()) >= HIGH_BIT) {
					c |= (curr & 0x7f) << shift;
					shift += 7;
				}
				c |= curr << shift;
				data[i] = (char) c;
			}
		}
	}