Beispiel #1
0
        public FileService()
        {
            desGlobal = DES.Create();
            var bytes = Encoding.ASCII.GetBytes(Key);

            desGlobal.Key  = bytes;
            desGlobal.IV   = bytes;
            Root           = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName;
            AccessFilePath = Path.Combine(new String[] {
                Root,
                "IB1",
                "Data",
                "user.json"
            });
            CryptoProgramm = Path.Combine(new String[] {
                Root,
                "IB1",
                "Crypto",
                "main.exe"
            });
            TempFilePath = Path.Combine(new String[] {
                Root,
                "IB1",
                "Data",
                "temp.json"
            });
            var admin = new UserModel()
            {
                UserName = "******", Password = string.Empty, Lockout = AccountLockout.OK, PasswordRestriction = PasswordRestriction.MustBe
            };

            if (!CreateAccessFile())
            {
                try
                {
                    UserList.Add(admin);
                    var add = UserList.GetUser(admin);
                    RunGolangAndWriteFile();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    System.Environment.Exit(0);
                }
            }
            else
            {
                try
                {
                    RunGolangAndReadFile();
                    var add = UserList.GetUser(admin);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    System.Environment.Exit(0);
                }
            }
        }
Beispiel #2
0
        public DataController()
        {
            Des      = DES.Create();
            Des.Mode = CipherMode.CFB;
            var bytes = Encoding.ASCII.GetBytes(FirstKey + SecondKey);

            Des.Key = bytes;
            Des.IV  = bytes;

            RootPath = Directory.GetParent(Environment.CurrentDirectory).Parent.Parent.FullName;

            FilePath = Path.Combine(new String[] {
                RootPath,
                "IS_1",
                "Data",
                "user.json"
            });

            var admin = new UserModel()
            {
                Login               = "******",
                Password            = String.Empty,
                AuthCnt             = 0,
                Rule                = true,
                PasswordRestriction = false
            };

            if (!CreateDataFile())
            {
                try
                {
                    UserList.Add(admin);
                    var add = UserList.Get(admin);
                    BaseDESEncode();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    System.Environment.Exit(0);
                }
            }
            else
            {
                try
                {
                    BaseDESDecode();
                    var add = UserList.Get(admin);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.ToString());
                    System.Environment.Exit(0);
                }
            }
        }