@Test public void testToChecksumAddress() { assertThat(Keys.toChecksumAddress("0xfb6916095ca1df60bb79ce92ce3ea74c37c5d359"), is("0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359")); assertThat(Keys.toChecksumAddress("0x52908400098527886E0F7030069857D2E4169EE7"), is("0x52908400098527886E0F7030069857D2E4169EE7")); assertThat(Keys.toChecksumAddress("0x8617E340B3D01FA5F11F306F4090FD50E238070D"), is("0x8617E340B3D01FA5F11F306F4090FD50E238070D")); assertThat(Keys.toChecksumAddress("0xde709f2102306220921060314715629080e2fb77"), is("0xde709f2102306220921060314715629080e2fb77")); assertThat(Keys.toChecksumAddress("0x27b1fdb04752bbc536007a920d24acb045561c26"), is("0x27b1fdb04752bbc536007a920d24acb045561c26")); assertThat(Keys.toChecksumAddress("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed"), is("0x5aAeb6053F3E94C9b9A09f33669435E7Ef1BeAed")); assertThat(Keys.toChecksumAddress("0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359"), is("0xfB6916095ca1df60bB79Ce92cE3Ea74c37c5d359")); assertThat(Keys.toChecksumAddress("0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB"), is("0xdbF03B407c01E7cD3CBea99509d93f8DDDC8C6FB")); assertThat(Keys.toChecksumAddress("0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb"), is("0xD1220A0cf47c7B9Be7A2E6BA89F429762e7b9aDb")); }
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(); }
Keys { 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(); } }
Keys { 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(); } private  Keys(); }
Keys { 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(); } private  Keys(); static ECKeyPair createEcKeyPair(); static String getAddress(ECKeyPair ecKeyPair); static String getAddress(BigInteger publicKey); static String getAddress(String publicKey); static byte[] getAddress(byte[] publicKey); static String toChecksumAddress(String address); static byte[] serialize(ECKeyPair ecKeyPair); static ECKeyPair deserialize(byte[] input); }
Keys { 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(); } private  Keys(); static ECKeyPair createEcKeyPair(); static String getAddress(ECKeyPair ecKeyPair); static String getAddress(BigInteger publicKey); static String getAddress(String publicKey); static byte[] getAddress(byte[] publicKey); static String toChecksumAddress(String address); static byte[] serialize(ECKeyPair ecKeyPair); static ECKeyPair deserialize(byte[] input); static final int ADDRESS_SIZE; static final int ADDRESS_LENGTH_IN_HEX; static final int PRIVATE_KEY_LENGTH_IN_HEX; }