Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Text;
- using Sys = Cosmos.System;
- using Cosmos.System.FileSystem;
- using Cosmos.System.FileSystem.VFS;
- using System.IO;
- using Cosmos.HAL;
- using System.Security.Cryptography;
- using System.Net;
- namespace OS_Test
- {
- public class Kernel : Sys.Kernel
- {
- protected override void BeforeRun()
- {
- Console.Clear();
- Console.WriteLine("Loaded BronzeOS.");
- Console.WriteLine("Created by GtaMasterYT!");
- var fs = new CosmosVFS();
- VFSManager.RegisterVFS(fs);
- fs.Initialize();
- }
- protected override void Run()
- {
- var foldercheck = @"0:\BronzeOS\";
- if (!Directory.Exists(foldercheck))
- {
- Directory.CreateDirectory(foldercheck);
- }
- var firstRunCheck = @"0:\BronzeOS\firstrun.dat";
- if (!File.Exists(firstRunCheck))
- {
- File.Create(firstRunCheck);
- File.WriteAllText(firstRunCheck, "0");
- }
- if (File.ReadAllText(firstRunCheck) == "0")
- {
- initiateFirstRun();
- }
- Console.WriteLine();
- }
- private static readonly RandomNumberGenerator Random = RandomNumberGenerator.Create();
- // Login Variables
- // TODO: Login
- public static readonly int BlockBitSize = 128;
- public static readonly int KeyBitSize = 256;
- public static readonly int SaltBitSize = 64;
- public static readonly int Iterations = 10000;
- public static readonly int MinPasswordLength = 12;
- public static byte[] NewKey()
- {
- var key = new byte[KeyBitSize / 8];
- Random.GetBytes(key);
- return key;
- }
- public void runOS()
- {
- Console.WriteLine("Test.");
- Stop();
- }
- public void loginOS()
- {
- Console.Clear();
- Console.WriteLine("Welcome to BronzeOS!");
- Console.WriteLine("Please enter your username.");
- Console.Write(">");
- string username = Console.ReadLine();
- Console.WriteLine("Please enter your password.");
- Console.Write(">");
- string password = Console.ReadLine();
- if(password != "" && username != "")
- {
- if(File.ReadAllLines(@"0:\BronzeOS\login.dat")[0] == username && File.ReadAllLines(@"0:\BronzeOS\login.dat")[1] == password)
- {
- runOS();
- }
- }
- else
- {
- Console.WriteLine("Please enter actual login information.");
- loginOS();
- }
- }
- // First Run Function
- public void initiateFirstRun()
- {
- Console.Clear();
- Console.WriteLine("Welcome to BronzeOS!");
- Console.WriteLine("Please enter your username.");
- Console.Write(">");
- string username = Console.ReadLine();
- Console.WriteLine("Please enter your password.");
- Console.Write(">");
- string password = Console.ReadLine();
- if (password != "" && username != "")
- {
- if (!File.Exists(@"0:\BronzeOS\login.dat"))
- {
- File.Create(@"0:\BronzeOS\login.dat");
- }
- File.WriteAllText(@"0:\BronzeOS\login.dat", username + "\n" + password);
- }
- else
- {
- Console.WriteLine("Your username or password was empty. Please try again.");
- initiateFirstRun();
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement