コード例 #1
0
        public static void Deleteuser(string user)
        {
            bool   verify = Connectimimedb.verify(user);
            string path   = "C:\\Users\\Lenovo\\Desktop\\Detyra1_DS-Gr-6-master\\ds\\bin\\Debug\\netcoreapp3.0\\keys\\" + user + ".pem";
            string path1  = "C:\\Users\\Lenovo\\Desktop\\Detyra1_DS-Gr-6-master\\ds\\bin\\Debug\\netcoreapp3.0\\keys\\" + user + ".pub.pem";


            if (File.Exists(path) && File.Exists(path1))
            {
                File.Delete(path);
                Console.WriteLine("Eshte larguar celsesi privat" + path);
                File.Delete(path1);
                Console.WriteLine("Eshte larguar celsesi public" + path1);
                Connectimimedb.DeleteStudent(user);
            }
            else if (!File.Exists(path) && File.Exists(path1))
            {
                File.Delete(path1);
                Console.WriteLine("Eshte larguar celesi public" + path1);
                Connectimimedb.DeleteStudent(user);
            }
            else
            {
                Console.WriteLine("Useri nuk ekziston");
            }
        }
コード例 #2
0
ファイル: Login.cs プロジェクト: omermehmeti/data_security
        public static bool VerifyPassword(string user, string password)
        {
            string PASS = Connectimimedb.GetSalt(user, false);
            // Console.WriteLine(PASS);

            string testhash = GjeneroSalt.GjeneroSHA256Hashin(password, PASS);
            // Console.WriteLine(testhash);
            string dbHash = Connectimimedb.GetSalt(user, true);

            if (dbHash == testhash)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
コード例 #3
0
        public static void Createuser(string user)
        {
            Connectimimedb.InsertStudent(user);
            Chilkat.Global glob = new Chilkat.Global();
            Chilkat.Rsa    rsa  = new Chilkat.Rsa();
            glob.UnlockBundle("hELLOW");



            // Generate a 1024-bit key.  Chilkat RSA supports
            // key sizes ranging from 512 bits to 4096 bits.
            bool success = rsa.GenerateKey(1024);

            if (success != true)
            {
                Console.WriteLine(rsa.LastErrorText);
                return;
            }

            // Keys are exported in XML format:
            string publicKeyXml = rsa.ExportPublicKey();


            string privateKeyXml = rsa.ExportPrivateKey();


            // Save the private key in PEM format:
            Chilkat.PrivateKey privKey = new Chilkat.PrivateKey();
            success = privKey.LoadXml(privateKeyXml);
            success = privKey.SaveRsaPemFile("C:\\Users\\Lenovo\\Desktop\\Detyra1_DS-Gr-6-master\\ds\\bin\\Debug\\netcoreapp3.0\\keys\\" + user + ".pem");
            Console.WriteLine("Eshte krijuar qelesi privat " + "keys\\" + user + ".pem");
            // Save the public key in PEM format:
            Chilkat.PublicKey pubKey = new Chilkat.PublicKey();
            success = pubKey.LoadXml(publicKeyXml);
            success = pubKey.SaveOpenSslPemFile("C:\\Users\\Lenovo\\Desktop\\Detyra1_DS-Gr-6-master\\ds\\bin\\Debug\\netcoreapp3.0\\keys\\" + user + ".pub.pem");
            Console.WriteLine("Eshte krijuar qelesi public " + "keys\\" + user + ".pub.pem");
        }