예제 #1
0
        public static string DecryptPass(byte[] array)
        {
            CryptoDES objCryptoDES = new CryptoDES();

            objCryptoDES.Initialize();
            string info = ByteArrayToStr(array);

            info = objCryptoDES.DESSelfDecrypt(info);
            return(info);
        }
예제 #2
0
        public static void saveData(List <Term> termTable)
        {
            StreamWriter    termFile = new StreamWriter("term.txt");
            CryptoSymmetric crypto   = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });

            foreach (var item in termTable)
            {
                var tempString = item.TermNum.ToString() + "\t" + item.TermName.ToString();
                termFile.WriteLine(crypto.Encrypt(tempString));
            }
            termFile.Close();
        }
예제 #3
0
        public static void saveData(List <PreQuisite> Table)
        {
            StreamWriter    PreqFile = new StreamWriter("prerequisite.txt");
            CryptoSymmetric crypto   = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });

            foreach (var item in Table)
            {
                var tempString = item.Course1.Id.ToString() + "\t" + item.Course2.Id.ToString() + "\t" + item.Status.ToString();
                PreqFile.WriteLine(crypto.Encrypt(tempString));
            }
            PreqFile.Close();
        }
예제 #4
0
        public static void saveData(List <Clerk> ClerkTable)
        {
            StreamWriter    ClerkFile = new StreamWriter("clerk.txt");
            CryptoSymmetric crypto    = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });

            foreach (var item in ClerkTable)
            {
                var tempString = item.Id.ToString() + "\t" + item.FirstName.ToString() + "\t" + item.LastName.ToString() + "\t" + item.Password.ToString();
                ClerkFile.WriteLine(crypto.Encrypt(tempString));
            }
            ClerkFile.Close();
        }
예제 #5
0
        public static void saveData(List <Course> CourseTable)
        {
            StreamWriter    CourseFile = new StreamWriter("course.txt");
            CryptoSymmetric crypto     = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });

            foreach (var item in CourseTable)
            {
                var tempString = String.Format("{0}\t{1}\t{2}\t{3}", item.Id, item.ECT, item.Name, item.type);
                CourseFile.WriteLine(crypto.Encrypt(tempString));
            }
            CourseFile.Close();
        }
예제 #6
0
        public static void saveData(List <TermCourseStudent> termCourseStudentTable)
        {
            StreamWriter    termCourseStudentFile = new StreamWriter("termcoursestudent.txt");
            CryptoSymmetric crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });

            foreach (var item in termCourseStudentTable)
            {
                var tempString = item.Mark.ToString() + "\t" + item.AnswerToObjection.ToString() + "\t" + item.ObjectionToMark.ToString() + "\t" + item.TermCourse.Id.ToString() + "\t" + item.Student.Id.ToString() + "\t" + item.Status.ToString();
                termCourseStudentFile.WriteLine(crypto.Encrypt(tempString));
            }
            termCourseStudentFile.Close();
        }
예제 #7
0
        public static void saveData(List <TermCourse> termCourseTable)
        {
            StreamWriter    file   = new StreamWriter("termcourse.txt");
            CryptoSymmetric crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });

            foreach (var item in termCourseTable)
            {
                var tempString = item.Id.ToString() + "\t" + item.Course.Id.ToString() + "\t" + item.Term.TermNum.ToString() + "\t" + item.Teacher.Id.ToString() + "\t" + item.Time + "\t" + item.Place + "\t" + item.Capacity;
                file.WriteLine(crypto.Encrypt(tempString));
            }
            file.Close();
        }
예제 #8
0
        public static void saveData(List <Student> studentTable)
        {
            StreamWriter    file   = new StreamWriter("student.txt");
            CryptoSymmetric crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });

            foreach (var item in studentTable)
            {
                var tempString = item.Id.ToString() + "\t" + item.FirstName.ToString() + "\t" + item.LastName.ToString() + "\t" + item.Password.ToString() + "\t" + item.EntranceYear;
                file.WriteLine(crypto.Encrypt(tempString));
            }
            file.Close();
        }
예제 #9
0
 public static byte[] EncryptPass(string pass)
 {
     try
     {
         CryptoDES objCryptoDES = new CryptoDES();
         objCryptoDES.Initialize();
         string encryptSTR = objCryptoDES.DESSelfEncrypt(pass);
         byte[] contents   = StrToByteArray(encryptSTR);
         return(contents);
     }
     catch (Exception oEx)
     {
         LoggingHelper.ShowMessage(oEx);
         return(null);
     }
 }
예제 #10
0
        public void CryptoDES_RandomIV_Test()
        {
            //Arrange
            byte[] key = { 158, 23, 64, 96, 57, 225, 36, 85 };

            CryptoSymmetric crypto           = new CryptoDES(key);
            string          originalMessage  = "I love cryptography and DES with a 64-bits key";
            string          encryptedMessage = crypto.Encrypt(originalMessage);

            //Act
            string decryptedMessage = crypto.Decrypt(encryptedMessage);

            //Assert
            Assert.AreNotEqual(originalMessage, encryptedMessage);
            Assert.AreEqual(originalMessage, decryptedMessage);
        }
예제 #11
0
        public void CryptoDES_FixedIV_Test()
        {
            //Arrange
            byte[] key = { 158, 23, 64, 96, 57, 225, 36, 85 };
            byte[] iv  = { 63, 208, 159, 46, 37, 77, 1, 59 };

            CryptoSymmetric crypto = new CryptoDES(key);

            crypto.SetIV(iv);
            string originalMessage  = "I love cryptography and DES with a 64-bits key";
            string encryptedMessage = crypto.Encrypt(originalMessage);

            //Act
            string decryptedMessage = crypto.Decrypt(encryptedMessage);

            //Assert
            Assert.AreNotEqual(originalMessage, encryptedMessage);
            Assert.AreEqual(originalMessage, decryptedMessage);
        }
예제 #12
0
파일: Helper.cs 프로젝트: erdincay/db4o
		public static string DecryptPass(byte[] array)
		{
			CryptoDES objCryptoDES = new CryptoDES();
			objCryptoDES.Initialize();
			string info = ByteArrayToStr(array);
			info = objCryptoDES.DESSelfDecrypt(info);
			return info;
		}
예제 #13
0
파일: Helper.cs 프로젝트: erdincay/db4o
		public static byte[] EncryptPass(string pass)
		{
			try
			{
				CryptoDES objCryptoDES = new CryptoDES();
				objCryptoDES.Initialize();
				string encryptSTR = objCryptoDES.DESSelfEncrypt(pass);
				byte[] contents = StrToByteArray(encryptSTR);
				return contents;
			}
			catch (Exception oEx)
			{
				LoggingHelper.ShowMessage(oEx);
				return null;
			}

		}
예제 #14
0
        public static void loadData()
        {
            string line = "";

            StreamReader    studentFile = new StreamReader("student.txt");
            CryptoSymmetric crypto      = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });

            while ((line = studentFile.ReadLine()) != null)
            {
                line = crypto.Decrypt(line);
                var items = line.Split('\t');
                StudentTable.Add(new Student()
                {
                    Id = int.Parse(items[0]), FirstName = items[1], LastName = items[2], Password = items[3], EntranceYear = items[4].ToString()
                });
            }
            studentFile.Close();
            StreamReader teacherFile = new StreamReader("teacher.txt");

            crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });
            while ((line = teacherFile.ReadLine()) != null)
            {
                line = crypto.Decrypt(line);
                var items = line.Split('\t');
                TeacherTable.Add(new Teacher()
                {
                    Id = int.Parse(items[0]), FirstName = items[1], LastName = items[3], Password = items[3]
                });
            }
            teacherFile.Close();

            StreamReader courseFile = new StreamReader("course.txt");

            crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });
            while ((line = courseFile.ReadLine()) != null)
            {
                line = crypto.Decrypt(line);
                var items = line.Split('\t');
                CourseTable.Add(new Course()
                {
                    Id = int.Parse(items[0]), ECT = int.Parse(items[1]), Name = items[2], type = items[3]
                });
            }
            courseFile.Close();

            StreamReader termFile = new StreamReader("term.txt");

            crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });
            while ((line = termFile.ReadLine()) != null)
            {
                line = crypto.Decrypt(line);
                var items = line.Split('\t');
                TermTable.Add(new Term()
                {
                    TermNum = int.Parse(items[0])
                    ,
                    TermName = items[1]
                });
            }
            termFile.Close();

            StreamReader prereQuisiteFile = new StreamReader("prerequisite.txt");

            crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });
            while ((line = prereQuisiteFile.ReadLine()) != null)
            {
                line = crypto.Decrypt(line);
                var items = line.Split('\t');
                preQuisiteTable.Add(new PreQuisite()
                {
                    Course1 = (CourseTable.Select(x => x).Where(x => x.Id == int.Parse(items[0])).ToArray())[0]
                    ,
                    Course2 = (CourseTable.Select(x => x).Where(x => x.Id == int.Parse(items[1])).ToArray())[0]
                    ,
                    Status = items[2]
                });
            }
            prereQuisiteFile.Close();

            StreamReader termCourseFile = new StreamReader("termcourse.txt");

            crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });
            while ((line = termCourseFile.ReadLine()) != null)
            {
                line = crypto.Decrypt(line);
                var items = line.Split('\t');
                termCourseTable.Add(new TermCourse()
                {
                    Id       = int.Parse(items[0]),
                    Course   = (CourseTable.Select(x => x).Where(x => x.Id == int.Parse(items[1])).ToArray())[0],
                    Term     = (TermTable.Select(x => x).Where(x => x.TermNum == int.Parse(items[2])).ToArray())[0],
                    Teacher  = (TeacherTable.Select(x => x).Where(x => x.Id == int.Parse(items[3])).ToArray())[0],
                    Time     = int.Parse(items[4]),
                    Place    = items[5],
                    Capacity = int.Parse(items[6])
                });
                ;
            }
            termCourseFile.Close();

            StreamReader termCourseStudentFile = new StreamReader("termcoursestudent.txt");

            crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });
            while ((line = termCourseStudentFile.ReadLine()) != null)
            {
                line = crypto.Decrypt(line);
                var items = line.Split('\t');
                termCourseStudentTable.Add(new TermCourseStudent()
                {
                    Mark = double.Parse(items[0])
                    ,
                    ObjectionToMark = items[1]
                    ,
                    AnswerToObjection = items[2]
                    ,
                    TermCourse = (termCourseTable.Select(x => x).Where(x => x.Id == int.Parse(items[3])).ToArray())[0]
                    ,
                    Student = (StudentTable.Select(x => x).Where(x => x.Id == int.Parse(items[4])).ToArray())[0]
                    ,
                    Status = items[5]
                });
            }

            termCourseStudentFile.Close();
            StreamReader clerkFile = new StreamReader("clerk.txt");

            crypto = new CryptoDES(new byte[] { 158, 23, 64, 96, 57, 225, 36, 85 });
            while ((line = clerkFile.ReadLine()) != null)
            {
                line = crypto.Decrypt(line);
                var items = line.Split('\t');
                ClerkTable.Add(new Clerk()
                {
                    Id = int.Parse(items[0])
                    ,
                    FirstName = items[1]
                    ,
                    LastName = items[2]
                    ,
                    Password = items[3]
                });
            }
            clerkFile.Close();
        }