@Test public void testEncodeChecked_address() throws Exception { String encoded = Base58.encodeChecked(111, new byte[Address.LENGTH]); assertEquals("mfWxJ45yp2SFn7UciZyNpvDKrzbhyfKrY8", encoded); }
public static String encodeChecked(int version, byte[] payload) { if (version < 0 || version > 255) throw new IllegalArgumentException("Version not in range."); byte[] addressBytes = new byte[1 + payload.length + 4]; addressBytes[0] = (byte) version; System.arraycopy(payload, 0, addressBytes, 1, payload.length); byte[] checksum = Sha256Hash.hashTwice(addressBytes, 0, payload.length + 1); System.arraycopy(checksum, 0, addressBytes, payload.length + 1, 4); return Base58.encode(addressBytes); }
Base58 { public static String encodeChecked(int version, byte[] payload) { if (version < 0 || version > 255) throw new IllegalArgumentException("Version not in range."); byte[] addressBytes = new byte[1 + payload.length + 4]; addressBytes[0] = (byte) version; System.arraycopy(payload, 0, addressBytes, 1, payload.length); byte[] checksum = Sha256Hash.hashTwice(addressBytes, 0, payload.length + 1); System.arraycopy(checksum, 0, addressBytes, payload.length + 1, 4); return Base58.encode(addressBytes); } }
Base58 { public static String encodeChecked(int version, byte[] payload) { if (version < 0 || version > 255) throw new IllegalArgumentException("Version not in range."); byte[] addressBytes = new byte[1 + payload.length + 4]; addressBytes[0] = (byte) version; System.arraycopy(payload, 0, addressBytes, 1, payload.length); byte[] checksum = Sha256Hash.hashTwice(addressBytes, 0, payload.length + 1); System.arraycopy(checksum, 0, addressBytes, payload.length + 1, 4); return Base58.encode(addressBytes); }  }
Base58 { public static String encodeChecked(int version, byte[] payload) { if (version < 0 || version > 255) throw new IllegalArgumentException("Version not in range."); byte[] addressBytes = new byte[1 + payload.length + 4]; addressBytes[0] = (byte) version; System.arraycopy(payload, 0, addressBytes, 1, payload.length); byte[] checksum = Sha256Hash.hashTwice(addressBytes, 0, payload.length + 1); System.arraycopy(checksum, 0, addressBytes, payload.length + 1, 4); return Base58.encode(addressBytes); }  static String encode(byte[] input); static String encodeChecked(int version, byte[] payload); static byte[] decode(String input); static BigInteger decodeToBigInteger(String input); static byte[] decodeChecked(String input); }
Base58 { public static String encodeChecked(int version, byte[] payload) { if (version < 0 || version > 255) throw new IllegalArgumentException("Version not in range."); byte[] addressBytes = new byte[1 + payload.length + 4]; addressBytes[0] = (byte) version; System.arraycopy(payload, 0, addressBytes, 1, payload.length); byte[] checksum = Sha256Hash.hashTwice(addressBytes, 0, payload.length + 1); System.arraycopy(checksum, 0, addressBytes, payload.length + 1, 4); return Base58.encode(addressBytes); }  static String encode(byte[] input); static String encodeChecked(int version, byte[] payload); static byte[] decode(String input); static BigInteger decodeToBigInteger(String input); static byte[] decodeChecked(String input); static final char[] ALPHABET; }