Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace HeiseCalculator
- {
- class Program
- {
- static bool[] ip_1 = new bool[32];
- static bool[] ip_2 = new bool[32];
- static void Main(string[] args)
- {
- //Console.WriteLine("Enter ip1");
- //string a = Console.ReadLine();
- //Console.WriteLine("Enter ip2");
- //string b = Console.ReadLine();
- //Console.WriteLine("Are these IPs correct?\n{0}\n{1}\ny/n", a, b);
- //Console.WriteLine("Press enter to continue...");
- string ip = "193.99.144.85";
- string ip2 = "213.61.187.98";
- Console.WriteLine(ip);
- ip_1 = ConvertToIP(ip);
- ip_2 = ConvertToIP(ip2);
- int cidr = CalculateCIDR(ip_1, ip_2);
- Console.ReadKey();
- }
- static bool[] ConvertToIP(string ip)
- {
- bool[] arr_b = new bool[32];
- string[] arr = ip.Split('.');
- for (int i = 0; i < arr.Length; i++)
- {
- arr[i] = Convert.ToString(Convert.ToInt32(arr[i], 10),2).PadLeft(8, '0');
- }
- int a = 0;
- ip = string.Concat(arr[0], arr[1], arr[2], arr[3]);
- Console.WriteLine(ip);
- for (int i = 0; i < ip.Length; i++)
- {
- if (ip[i] == '1')
- {
- arr_b[i] = true;
- }
- if (ip[i] == '0')
- {
- arr_b[i] = false;
- }
- }
- return arr_b;
- }
- static int CalculateCIDR(bool[] ip_1, bool[] ip_2)
- {
- int a = 0;
- while (ip_1[a] == ip_2[a])
- {
- a++;
- }
- return a;
- }
- static int CalculateIP(bool[] ip, int cidr)
- {
- }
- static void CVtoBinary(string dec)
- {
- }
- static string ConvertToDecimal(bool[] ip)
- {
- return null;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement