Accepts a string address and turns it into binary.

        Makes sure that the string address provided starts is 0x prefixed and
        checksummed according to EIP55 specification
761665
def address_checksum_and_decode(addr: str) -> Address:
    
    if not is_0x_prefixed(addr):
        raise InvalidAddress('Address must be 0x prefixed')

    if not is_checksum_address(addr):
        raise InvalidAddress('Address must be EIP55 checksummed')

    addr_bytes = decode_hex(addr)
    assert len(addr_bytes) in (20, 0)
    return Address(addr_bytes)
137083
def fromhexstring(cls, hexstring):
        
        bitstring = format(int(hexstring, 16), "0" + str(len(hexstring)/4) + "b")
        return cls.fromstring(bitstring)
965672
def fromBinaryString(value):
        
        bitNo = 8
        byte = 0
        r = []
        for v in value:
            if bitNo:
                bitNo -= 1
            else:
                bitNo = 7
                r.append(byte)
                byte = 0
            if v in ('0', '1'):
                v = int(v)
            else:
                raise error.PyAsn1Error(
                    'Non-binary OCTET STRING initializer %s' % (v,)
                )
            byte |= v << bitNo

        r.append(byte)

        return octets.ints2octs(r)
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;
    }
364268
def _sync_string_to(bin_or_str, string):
    

    if isinstance(string, type(bin_or_str)):
        return string
    elif isinstance(string, binary_type):
        return string.decode(DEFAULT_ENCODING)
    else:
        return string.encode(DEFAULT_ENCODING)
1044705
private StringBuilder adjustBinaryString(String binaryString, boolean compact, int layers) {

        StringBuilder adjustedString = new StringBuilder();
        int codewordSize = getCodewordSize(layers);

        for (int i = 0, j = 0; i < binaryString.length(); ) {
            if (((j + 1) % codewordSize) == 0) {
                /* Last bit of codeword */
                boolean done = false;
                int ones = 0;
                for (int t = 0; t < (codewordSize - 1); t++) {
                    if (binaryString.charAt((i - (codewordSize - 1)) + t) == '1') {
                        ones++;
                    }
                }
                if (ones == (codewordSize - 1)) {
                    adjustedString.append('0');
                    j++;
                    done = true;
                }
                if (ones == 0) {
                    adjustedString.append('1');
                    j++;
                    done = true;
                }
                if (!done) {
                    adjustedString.append(binaryString.charAt(i));
                    j++;
                    i++;
                }
            } else {
                adjustedString.append(binaryString.charAt(i));
                j++;
                i++;
            }
        }

        int adjustedLength = adjustedString.length();
        int remainder = adjustedLength % codewordSize;

        /* Add padding */
        int padBits = codewordSize - remainder;
        if (padBits == codewordSize) {
            padBits = 0;
        }
        for (int i = 0; i < padBits; i++) {
            adjustedString.append('1');
        }
        adjustedLength = adjustedString.length();

        /* Make sure padding didn't create an invalid (all 1s) codeword */
        int count = 0;
        for (int i = Math.max(adjustedLength - codewordSize, 0); i < adjustedLength; i++) {
            if (adjustedString.charAt(i) == '1') {
                count++;
            }
        }
        if (count == codewordSize) {
            adjustedString.setCharAt(adjustedLength - 1, '0');
        }

        /* Check if the data actually fits into the selected symbol size */
        int dataMaxSize;
        if (compact) {
            dataMaxSize = codewordSize * (AZTEC_COMPACT_SIZES[layers - 1] - 3);
        } else {
            dataMaxSize = codewordSize * (AZTEC_SIZES[layers - 1] - 3);
        }

        if (adjustedLength > dataMaxSize) {
            throw new OkapiException("Data too long for specified Aztec Code symbol size");
        }

        /* Log the codewords */
        encodeInfo += "Codewords: ";
        for (int i = 0; i < (adjustedLength / codewordSize); i++) {
            int l = 0, m = (1 << (codewordSize - 1));
            for (int j = 0; j < codewordSize; j++) {
                if (adjustedString.charAt((i * codewordSize) + j) == '1') {
                    l += m;
                }
                m = m >> 1;
            }
            encodeInfo += Integer.toString(l) + " ";
        }
        encodeInfo += "\n";

        /* Return the adjusted bit string */
        return adjustedString;
    }
346966
def binary_value(self):
        
        str_raw_value = str(self.raw_value)
        if len(str_raw_value) % 2 == 1:
            str_raw_value = '0' + str_raw_value

        return binascii.unhexlify(str_raw_value)
808114
def _isbtaddr(address):
    
    # Define validity regex. Accept either ":" or "-" as separators.
    global _validbtaddr
    if _validbtaddr is None:
        import re
        _validbtaddr = re.compile("((\d|[a-f]){2}(:|-)){5}(\d|[a-f]){2}",
                re.IGNORECASE)
    import types
    if not isinstance(address, str):
        return False
    return _validbtaddr.match(address) is not None
1024807
public static String bytesToIpAddress(byte[] bytes, int offset, int length) {
        switch (length) {
            case 4: {
                return new StringBuilder(15)
                        .append(bytes[offset] & 0xff)
                        .append('.')
                        .append(bytes[offset + 1] & 0xff)
                        .append('.')
                        .append(bytes[offset + 2] & 0xff)
                        .append('.')
                        .append(bytes[offset + 3] & 0xff).toString();
            }
            case 16:
                return toAddressString(bytes, offset, false);
            default:
                throw new IllegalArgumentException("length: " + length + " (expected: 4 or 16)");
        }
    }
20348
def validipaddr(address):
    
    try:
        octets = address.split('.')
        if len(octets) != 4:
            return False
        for x in octets:
            if not (0 <= int(x) <= 255):
                return False
    except ValueError:
        return False
    return True
621188
def __write_byte(self, address, value):
        
        # Save previous address content.
        if address in self._memory:
            self.__memory_prev[address] = self._memory[address]

        self._memory[address] = value & 0xff
158659
private void addAddressToList(String newAddress, boolean validateOnly) {
        int start = 0;
        char delimiter = '.';
        String sub;
        int radix = 10;

        // Address initially set to all zeroes
        int addressToAdd[] = new int[IP_ADDR_NUMBERS];
        for (int i = 0; i < IP_ADDR_NUMBERS; i++) {
            addressToAdd[i] = 0;
        }

        int slot = IP_ADDR_NUMBERS - 1;
        // assume the address is IP4, but change to IP6 if there is a colon
        if (newAddress.indexOf('.') == -1) {
            // if no ".", then assume IPv6 Address
            delimiter = ':';
            radix = 16;
        }

        String addr = newAddress;
        while (true) {
            // fill address from back to front
            start = addr.lastIndexOf(delimiter);
            if (start != -1) {
                sub = addr.substring(start + 1);

                if (sub.trim().equals("*")) {
                    addressToAdd[slot] = -1; // 0xFFFFFFFF is the wildcard.
                } else {
                    addressToAdd[slot] = Integer.parseInt(sub, radix);
                }
            } else {
                if (addr.trim().equals("*")) {
                    addressToAdd[slot] = -1; // 0xFFFFFFFF is the wildcard.
                } else {
                    addressToAdd[slot] = Integer.parseInt(addr, radix);
                }
                break;
            }
            slot = slot - 1;
            addr = addr.substring(0, start);
        }

        if (!validateOnly) {
            putInList(addressToAdd);
        }
    }
1141321
public static String toChecksumAddress(String address) {
        String lowercaseAddress = Numeric.cleanHexPrefix(address).toLowerCase();
        String addressHash = Numeric.cleanHexPrefix(Hash.sha3String(lowercaseAddress));

        StringBuilder result = new StringBuilder(lowercaseAddress.length() + 2);

        result.append("0x");

        for (int i = 0; i < lowercaseAddress.length(); i++) {
            if (Integer.parseInt(String.valueOf(addressHash.charAt(i)), 16) >= 8) {
                result.append(String.valueOf(lowercaseAddress.charAt(i)).toUpperCase());
            } else {
                result.append(lowercaseAddress.charAt(i));
            }
        }

        return result.toString();
    }
1291443
function pubKeyToAddr(pubKey, pubKeyHash) {
  pubKeyHash = pubKeyHash || zconfig.mainnet.pubKeyHash;

  const hash160 = zcrypto.hash160(Buffer.from(pubKey, 'hex'));
  return bs58check.encode(Buffer.from(pubKeyHash + hash160, 'hex')).toString('hex');
}
106218
def stringify_address(addr, encoding='utf-8'):
    
    if isinstance(addr, bytes_type):
        return addr
    try:
        addr = addr.encode('ascii')
    except UnicodeEncodeError:
        if '@' in addr:
            localpart, domain = addr.split('@', 1)
            addr = b'@'.join([
                localpart.encode(encoding),
                domain.encode('idna'),
            ])
        else:
            addr = addr.encode(encoding)
    return addr.decode('utf-8')
1299019
def to_binary(value, encoding='utf-8'):
    
    if not value:
        return b''
    if isinstance(value, six.binary_type):
        return value
    if isinstance(value, six.text_type):
        return value.encode(encoding)
    return to_text(value).encode(encoding)
19946
def address_as_b58(addr):
    
    if is_c32_address(addr):
        return c32ToB58(addr)

    else:
        if check_address(addr):
            return addr
        else:
            raise ValueError('Address {} is not b58 or c32'.format(addr))