Skip to content

Instantly share code, notes, and snippets.

@Jire
Created October 19, 2016 21:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Jire/7de49a03d5e6df7733184eeccb0a05ad to your computer and use it in GitHub Desktop.
Save Jire/7de49a03d5e6df7733184eeccb0a05ad to your computer and use it in GitHub Desktop.
public final class VisionID {
public static void main(String[] args) {
long a = Byte.toUnsignedLong((byte) 68);
long b = Byte.toUnsignedLong((byte) 199);
long c = Byte.toUnsignedLong((byte) 163);
long d = Byte.toUnsignedLong((byte) 44);
long port = Short.toUnsignedLong((short) 65535);
long ip = (a << 40) | (b << 32) | (c << 24) | (d << 16) | port;
String id = Long.toString(ip, 36);
System.out.println("ID: " + id);
long decoded = Long.parseLong(id, 36);
long a2 = (decoded >> 40) & 0xFF;
long b2 = (decoded >> 32) & 0xFF;
long c2 = (decoded >> 24) & 0xFF;
long d2 = (decoded >> 16) & 0xFF;
long port2 = ip & 0xFFFF;
System.out.printf("IP: %d.%d.%d.%d:%d", a2, b2, c2, d2, port2);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment