public void setAddressFromPublicKeyBytes(byte[] pubKeyBytes) { this.address = Base58.encode(pubKeyBytes); }
public static boolean isKeyUnencrypted(String data) { if(data == null) return false; try { Base58.decode(data); return true; } catch (AddressFormatException e) { return false; } }
protected VersionedChecksummedBytes(String encoded) throws AddressFormatException { byte[] versionAndDataBytes = Base58.decodeChecked(encoded); byte versionByte = versionAndDataBytes[0]; version = versionByte & 0xFF; bytes = new byte[versionAndDataBytes.length - 1]; System.arraycopy(versionAndDataBytes, 1, bytes, 0, versionAndDataBytes.length - 1); }
@Test public void testDecode() throws Exception { byte[] testbytes = "Hello World".getBytes(); byte[] actualbytes = Base58.decode("JxF12TrwUP45BMd"); assertTrue(new String(actualbytes), Arrays.equals(testbytes, actualbytes)); assertTrue("1", Arrays.equals(Base58.decode("1"), new byte[1])); assertTrue("1111", Arrays.equals(Base58.decode("1111"), new byte[4])); Base58.decode("This isn't valid base58"); fail(); } catch (AddressFormatException e) { Base58.decodeChecked("4stwEBjT6FYyVV"); Base58.decodeChecked("4stwEBjT6FYyVW"); fail(); } catch (AddressFormatException e) { Base58.decodeChecked("4s"); fail(); } catch (AddressFormatException e) { assertEquals(0, Base58.decode("").length); Base58.decodeChecked("93VYUMzRG9DdbRP72uQXjaWibbQwygnvaCu9DumcqDjGybD864T");
@Test public void testDecodeToBigInteger() { byte[] input = Base58.decode("129"); assertEquals(new BigInteger(1, input), Base58.decodeToBigInteger("129")); } }
int outputStart = encoded.length; for (int inputStart = zeros; inputStart < input.length; ) { encoded[--outputStart] = ALPHABET[divmod(input, inputStart, 256, 58)]; if (input[inputStart] == 0) {
key = dumpedPrivateKey.getKey(); } else { BigInteger privKey = Base58.decodeToBigInteger(args[0]); key = ECKey.fromPrivate(privKey);
int outputStart = encoded.length; for (int inputStart = zeros; inputStart < input.length; ) { encoded[--outputStart] = ALPHABET[divmod(input, inputStart, 256, 58)]; if (input[inputStart] == 0) {
public void setPrivateKeyFromBytes(byte[] privKeyBytes) { this.privateKey = Base58.encode(privKeyBytes); }
public boolean isPrivateKeyEncrypted() { try { Base58.decode(privateKey); return false; }catch (Exception e){ return true; } }
protected VersionedChecksummedBytes(String encoded) throws AddressFormatException { byte[] versionAndDataBytes = Base58.decodeChecked(encoded); byte versionByte = versionAndDataBytes[0]; version = versionByte & 0xFF; bytes = new byte[versionAndDataBytes.length - 1]; System.arraycopy(versionAndDataBytes, 1, bytes, 0, versionAndDataBytes.length - 1); }
int outputStart = encoded.length; for (int inputStart = zeros; inputStart < input.length; ) { encoded[--outputStart] = ALPHABET[divmod(input, inputStart, 256, 58)]; if (input[inputStart] == 0) {
/** * Returns the base-58 encoded String representation of this * object, including version and checksum bytes. */ public final String toBase58() { // A stringified buffer is: // 1 byte version + data bytes + 4 bytes check code (a truncated hash) byte[] addressBytes = new byte[1 + bytes.length + 4]; addressBytes[0] = (byte) version; System.arraycopy(bytes, 0, addressBytes, 1, bytes.length); byte[] checksum = Sha256Hash.hashTwice(addressBytes, 0, bytes.length + 1); System.arraycopy(checksum, 0, addressBytes, bytes.length + 1, 4); return Base58.encode(addressBytes); }
public static BigInteger decodeToBigInteger(String input) throws AddressFormatException { return new BigInteger(1, decode(input)); }
protected VersionedChecksummedBytes(String encoded) throws AddressFormatException { byte[] versionAndDataBytes = Base58.decodeChecked(encoded); byte versionByte = versionAndDataBytes[0]; version = versionByte & 0xFF; bytes = new byte[versionAndDataBytes.length - 1]; System.arraycopy(versionAndDataBytes, 1, bytes, 0, versionAndDataBytes.length - 1); }
int outputStart = encoded.length; for (int inputStart = zeros; inputStart < input.length; ) { encoded[--outputStart] = ALPHABET[divmod(input, inputStart, 256, 58)]; if (input[inputStart] == 0) {
static String toBase58(byte[] ser) { return Base58.encode(addChecksum(ser)); }
public static BigInteger decodeToBigInteger(String input) throws AddressFormatException { return new BigInteger(1, decode(input)); }
protected VersionedChecksummedBytes(String encoded) throws AddressFormatException { byte[] versionAndDataBytes = Base58.decodeChecked(encoded); byte versionByte = versionAndDataBytes[0]; version = versionByte & 0xFF; bytes = new byte[versionAndDataBytes.length - 1]; System.arraycopy(versionAndDataBytes, 1, bytes, 0, versionAndDataBytes.length - 1); }
int outputStart = decoded.length; for (int inputStart = zeros; inputStart < input58.length; ) { decoded[--outputStart] = divmod(input58, inputStart, 58, 256); if (input58[inputStart] == 0) {