Ejemplo n.º 1
0
 /**
  * @param ipV4Text - ip v4 address e.g. 10.0.10.1
  * @return
  */
 String convertIPtoBin(String ipV4Text) {
   String[] addrArray = ipV4Text.split("\\.");
   long num = 0;
   for (int i = 0; i < addrArray.length; i++) {
     System.out.println("(" + i + ") " + addrArray[i]);
     int power = 3 - i;
     num += ((Integer.parseInt(addrArray[i]) % 256 * Math.pow(256, power)));
   }
   System.out.println("ip: " + ipV4Text + " = " + num + ";  0x" + Long.toHexString(num));
   return Long.toHexString(
       num); // do not prefix "0x", leave it at Seagull script as extra syntax will be required
             // e.g. 0x0001[ip]
 }
Ejemplo n.º 2
0
 static int nextRandomInRange(int Min, int Max) {
   int result = Min + (int) (Math.random() * ((Max - Min) + 1));
   return result;
 }