コード例 #1
0
ファイル: CreatingDoc.cs プロジェクト: BorisZhur/Reposit1
        private void Endofwork_Click(object sender, EventArgs e)
        {
            if (ActionSelectionBox.SelectedIndex >= 0)
            {
                if (NextuserselectionBox.SelectedIndex >= 0)
                {
                    if (!templateok)
                    {
                        object path = fullpath;
                        WordDoc.SaveAs2(ref path);
                        WordDoc.Close(ref miss, ref miss, ref miss);
                        WordApp.Quit(ref miss, ref miss, ref miss);
                    }

                    File file = new File(pathf, DocumentName.Text, NextuserselectionBox.Text, ActionSelectionBox.Text, form2.current.name, NoticeBox.Text);
                    System.IO.File.WriteAllBytes(file.pathtofile, Cryptfunc.AESEncrypt(System.IO.File.ReadAllBytes(file.pathtofile)));
                    Cryptfunc.Loging(file);
                    Cryptfunc.Signing(file);

                    this.Close();
                    form2.UpdateGrid();
                }
                else
                {
                    MessageBox.Show("Choose next user at first!");
                }
            }
            else
            {
                MessageBox.Show("Choose action at first!");
            }
        }
コード例 #2
0
ファイル: Cryptfunc.cs プロジェクト: BorisZhur/Reposit1
        public static void Signing(File f)
        {
            string filehash = Cryptfunc.GetHash(Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(f.pathtofile)));
            string logshash = Cryptfunc.GetHash(Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(f.pathtolog)));
            string strout   = filehash + " -- " + logshash;

            System.IO.File.WriteAllBytes(f.pathtosign, Cryptfunc.RSAEncrypt(System.Text.Encoding.Default.GetBytes(strout)));
        }
コード例 #3
0
ファイル: DetailsForm.cs プロジェクト: BorisZhur/Reposit1
        private void EndWork()
        {
            System.IO.File.WriteAllBytes(file.pathtofile, Cryptfunc.AESEncrypt(System.IO.File.ReadAllBytes(file.pathtofile)));
            Cryptfunc.Loging(file);
            Cryptfunc.Signing(file);

            MessageBox.Show("Changes accepted");
            this.Close();
        }
コード例 #4
0
        //get from file
        public File(string dir)
        {
            this.pathtofile = dir;

            while (dir[dir.Length - 1] != '.')
            {
                dir = dir.Remove(dir.Length - 1);
            }
            this.pathtosign = dir + "sig";
            this.pathtolog  = dir + "log";
            dir             = dir.Remove(dir.Length - 1);

            while (dir[dir.Length - 1] != '\\')
            {
                this.name += dir[dir.Length - 1];
                dir        = dir.Remove(dir.Length - 1);
            }
            this.name = new string(this.name.ToCharArray().Reverse().ToArray());

            if (this.IsSigExist())
            {
                string strfromsig = System.Text.Encoding.UTF8.GetString(Cryptfunc.RSADecrypt(System.IO.File.ReadAllBytes(this.pathtosign)));
                int    i          = 0;
                if (strfromsig.Contains(" -- "))
                {
                    while (strfromsig.Substring(i, 4) != " -- ")
                    {
                        this.filehashfromsig += strfromsig[i];
                        i++;
                    }
                    this.loghashfromsig = strfromsig.Remove(0, i + 4);
                }
            }

            this.goodfile = this.IsFileValid() && this.IsLogValid();
            if (this.goodfile)
            {
                string[] sep  = { "\r\n" };
                string   str1 = System.Text.Encoding.UTF8.GetString(Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(this.pathtolog)));
                string[] str  = str1.Split(sep, StringSplitOptions.RemoveEmptyEntries);
                logs = new List <Logline>();
                foreach (string s in str)
                {
                    this.logs.Add(new Logline(s));
                }

                int lastlog = logs.Count - 1;
                this.date     = logs[lastlog].date;
                this.note     = logs[lastlog].note;
                this.touser   = logs[lastlog].touser;
                this.fromuser = logs[lastlog].fromuser;
                this.state    = logs[lastlog].state;
            }
        }
コード例 #5
0
ファイル: DetailsForm.cs プロジェクト: BorisZhur/Reposit1
        private void DetailsForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (see)
            {
                WordDoc.Close(ref miss, ref miss, ref miss);
                WordApp.Quit(ref miss, ref miss, ref miss);

                System.IO.File.WriteAllBytes(file.pathtofile, Cryptfunc.AESEncrypt(compl));
            }
            form2.UpdateGrid();
        }
コード例 #6
0
ファイル: DetailsForm.cs プロジェクト: BorisZhur/Reposit1
        private void EditFile_Click(object sender, EventArgs e)
        {
            WordApp = new Word.Application()
            {
                Visible = true
            };
            System.IO.File.WriteAllBytes(file.pathtofile, Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(file.pathtofile)));
            object readOnly = false;
            object path     = file.pathtofile;

            WordDoc = WordApp.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
            WordDoc.Activate();

            Controlfunc.Makeitinvisible(EditFile, SeeLogs, Deletefile);
            Controlfunc.Makeitvisible(Chooseuserlabel, Chosenuser, ActionSelectionBox, Actionselectionlabel, NoteBox, Notelabel1, Notelabel2, EndwithoutSave, EndwithSave);
        }
コード例 #7
0
ファイル: DetailsForm.cs プロジェクト: BorisZhur/Reposit1
        private void Seefile_Click(object sender, EventArgs e)
        {
            WordApp = new Word.Application()
            {
                Visible = true
            };

            compl = Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(file.pathtofile));
            System.IO.File.WriteAllBytes(file.pathtofile, compl);
            object readOnly = false;
            object path     = file.pathtofile;

            WordDoc = WordApp.Documents.Open(ref path, ref miss, ref readOnly, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss, ref miss);
            WordDoc.Activate();

            Controlfunc.Makeitinvisible(Seefile, Deletefile);
            see = true;
        }
コード例 #8
0
 public bool IsLogValid()
 {
     if (this.IsSigExist() && this.IsLogsExist())
     {
         string filehash = Cryptfunc.GetHash(Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(this.pathtolog)));
         if (this.loghashfromsig == filehash)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
コード例 #9
0
ファイル: Userbasework.cs プロジェクト: BorisZhur/Reposit1
        private void ConfirmChanges_Click(object sender, EventArgs e)
        {
            List <User> ul            = new List <User>();
            int         leadercounter = 0;

            for (int i = 0; i < dataGridView.RowCount - 1; i++)
            {
                try
                {
                    string un = "", ua = "", up = "";
                    un = dataGridView.Rows[i].Cells[0].Value.ToString();
                    ua = dataGridView.Rows[i].Cells[1].Value.ToString();
                    if (ua == "Leadership")
                    {
                        leadercounter++;
                    }
                    up = dataGridView.Rows[i].Cells[2].Value.ToString();

                    ul.Add(new User(un, up));
                    ul[i].Accesslevel = ua;
                }
                catch (Exception) { }
            }
            if (leadercounter != 0)
            {
                string strout = "";
                foreach (User u in ul)
                {
                    strout += u.name + ' ' + u.accesslevel + ' ' + u.pass + "\r\n";
                }
                System.IO.File.WriteAllBytes(form1.pathtobase, Cryptfunc.AESEncrypt(System.Text.Encoding.UTF8.GetBytes(strout)));
                form1.userbase = ul;
                this.Close();
            }
            else
            {
                MessageBox.Show("Company need one leader at least!!!");
            }
        }
コード例 #10
0
 void Initializeuserbase()
 {
     string[] ch = { "\r\n" };
     string[] s  = System.Text.Encoding.UTF8.GetString(Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(pathtobase))).Split(ch, StringSplitOptions.RemoveEmptyEntries);
     foreach (string str in s)
     {
         string uname = "", upass = "";
         int    uaccess;
         int    i = 0;
         while (str[i] != ' ')
         {
             uname += str[i++];
         }
         i++;
         uaccess = int.Parse(str[i].ToString());
         i      += 2;
         while (i < str.Length)
         {
             upass += str[i++];
         }
         userbase.Add(new User(uname, uaccess, upass));
     }
 }
コード例 #11
0
ファイル: Cryptfunc.cs プロジェクト: BorisZhur/Reposit1
        public static void Loging(File f)
        {
            byte[] logs;
            if (f.IsLogsExist())
            {
                logs = Cryptfunc.AESDecrypt(System.IO.File.ReadAllBytes(f.pathtolog));
            }
            else
            {
                logs = null;
            }

            string laststr = f.state + " -- " + f.fromuser + " -- " + f.touser + " -- " + DateTime.Now + " -- " + f.note;

            if (logs != null)
            {
                string slogs = System.Text.Encoding.UTF8.GetString(logs);
                System.IO.File.WriteAllBytes(f.pathtolog, Cryptfunc.AESEncrypt(System.Text.Encoding.UTF8.GetBytes(slogs + "\r\n" + laststr)));
            }
            else
            {
                System.IO.File.WriteAllBytes(f.pathtolog, Cryptfunc.AESEncrypt(System.Text.Encoding.UTF8.GetBytes(laststr)));
            }
        }