Created
May 29, 2018 15:22
-
-
Save sbarisic/5ab4a24ad743831d272bd4a030339592 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Net; | |
namespace NetCalculator | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
string[] Input = @"193.253.23.143/25 | |
85.14.23.132/25 | |
215.54.233.12/30 | |
193.253.23.200/25 | |
192.168.23.214/24 | |
193.253.23.150/1 | |
85.14.23.232/30 | |
85.14.23.132/1 | |
193.253.23.22/24 | |
193.253.23.22/24 | |
85.14.23.32/24 | |
32.177.34.244/25".Trim().Split('\n').Select((In) => In.Trim()).ToArray(); | |
List<uint> IPs = new List<uint>(); | |
for (int i = 0; i < 12; i++) | |
{ | |
// Console.Write("Enter IP/Mask: "); | |
string[] IPMask = Input[i].Trim().Split('/'); | |
uint IPInt = BitConverter.ToUInt32(IPAddress.Parse(IPMask[0]).GetAddressBytes().Reverse().ToArray(), 0); | |
int BitNum = int.Parse(IPMask[1]); | |
uint Mask = 0; | |
if (BitNum != 0) | |
Mask = Convert.ToUInt32(new string('1', BitNum), 2); | |
uint MaskedIP = (IPInt ^ Mask) >> BitNum; | |
IPs.Add(MaskedIP); | |
} | |
for (int x = 0; x < IPs.Count; x++) | |
{ | |
for (int y = 0; y < IPs.Count; y++) | |
{ | |
if (x == y) | |
continue; | |
if (IPs[x] == IPs[y]) | |
Console.WriteLine("{0}. <-> {1}", x + 1, y + 1); | |
} | |
} | |
Console.ReadLine(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment