Advertisement
Guest User

Untitled

a guest
Nov 28th, 2018
179
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.81 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Text;
  4. using Sys = Cosmos.System;
  5. using Cosmos.System.FileSystem;
  6. using Cosmos.System.FileSystem.VFS;
  7. using System.IO;
  8. using Cosmos.HAL;
  9. using System.Security.Cryptography;
  10. using System.Net;
  11.  
  12. namespace OS_Test
  13. {
  14.     public class Kernel : Sys.Kernel
  15.     {
  16.         protected override void BeforeRun()
  17.         {
  18.             Console.Clear();
  19.             Console.WriteLine("Loaded BronzeOS.");
  20.             Console.WriteLine("Created by GtaMasterYT!");
  21.             var fs = new CosmosVFS();
  22.             VFSManager.RegisterVFS(fs);
  23.             fs.Initialize();
  24.         }
  25.  
  26.         protected override void Run()
  27.         {
  28.             var foldercheck = @"0:\BronzeOS\";
  29.             if (!Directory.Exists(foldercheck))
  30.             {
  31.                 Directory.CreateDirectory(foldercheck);
  32.             }
  33.             var firstRunCheck = @"0:\BronzeOS\firstrun.dat";
  34.             if (!File.Exists(firstRunCheck))
  35.             {
  36.                 File.Create(firstRunCheck);
  37.                 File.WriteAllText(firstRunCheck, "0");
  38.             }
  39.             if (File.ReadAllText(firstRunCheck) == "0")
  40.             {
  41.                 initiateFirstRun();
  42.             }
  43.             Console.WriteLine();
  44.         }
  45.         private static readonly RandomNumberGenerator Random = RandomNumberGenerator.Create();
  46.  
  47.         // Login Variables
  48.         // TODO: Login
  49.         public static readonly int BlockBitSize = 128;
  50.         public static readonly int KeyBitSize = 256;
  51.         public static readonly int SaltBitSize = 64;
  52.         public static readonly int Iterations = 10000;
  53.         public static readonly int MinPasswordLength = 12;
  54.         public static byte[] NewKey()
  55.         {
  56.             var key = new byte[KeyBitSize / 8];
  57.             Random.GetBytes(key);
  58.             return key;
  59.         }
  60.        
  61.         public void runOS()
  62.         {
  63.             Console.WriteLine("Test.");
  64.             Stop();
  65.         }
  66.        
  67.         public void loginOS()
  68.         {
  69.             Console.Clear();
  70.             Console.WriteLine("Welcome to BronzeOS!");
  71.             Console.WriteLine("Please enter your username.");
  72.             Console.Write(">");
  73.             string username = Console.ReadLine();
  74.             Console.WriteLine("Please enter your password.");
  75.             Console.Write(">");
  76.             string password = Console.ReadLine();
  77.             if(password != "" && username != "")
  78.             {
  79.                 if(File.ReadAllLines(@"0:\BronzeOS\login.dat")[0] == username && File.ReadAllLines(@"0:\BronzeOS\login.dat")[1] == password)
  80.                 {
  81.                     runOS();
  82.                 }
  83.             }
  84.             else
  85.             {
  86.                 Console.WriteLine("Please enter actual login information.");
  87.                 loginOS();
  88.             }
  89.         }
  90.  
  91.  
  92.         // First Run Function
  93.         public void initiateFirstRun()
  94.         {
  95.             Console.Clear();
  96.             Console.WriteLine("Welcome to BronzeOS!");
  97.             Console.WriteLine("Please enter your username.");
  98.             Console.Write(">");
  99.             string username = Console.ReadLine();
  100.             Console.WriteLine("Please enter your password.");
  101.             Console.Write(">");
  102.             string password = Console.ReadLine();
  103.             if (password != "" && username != "")
  104.             {
  105.                 if (!File.Exists(@"0:\BronzeOS\login.dat"))
  106.                 {
  107.                     File.Create(@"0:\BronzeOS\login.dat");
  108.                 }
  109.                 File.WriteAllText(@"0:\BronzeOS\login.dat", username + "\n" + password);
  110.             }
  111.             else
  112.             {
  113.                 Console.WriteLine("Your username or password was empty. Please try again.");
  114.                 initiateFirstRun();
  115.             }
  116.  
  117.  
  118.         }
  119.     }
  120. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement