Esempio n. 1
0
        public Boolean Decreypt(string encrypt, int ID)
        {
            //Get Public File
            GetKey  objKey     = new GetKey();
            DataRow drKey      = objKey.drSearchStudentKey(ID);
            string  PublicKey1 = drKey[0].ToString();

            // obtain an OpenPGP signed message
            String signedString = encrypt;

            // Extract the message and check the validity of the signature
            String plainText;

            // create an instance of the library
            PGPLib pgp = new PGPLib();
            SignatureCheckResult signatureCheck;

            try
            {
                signatureCheck = pgp.VerifyString(signedString,
                                                  new FileInfo(PublicKey1), out plainText);
            }
            catch
            {
                return(false);
            }



            string strData1 = plainText;

            // Print the results
            Console.WriteLine("Extracted plain text message is " + plainText);
            if (signatureCheck == SignatureCheckResult.SignatureVerified)
            {
                // Console.WriteLine("Signature OK");
                return(true);
            }
            else if (signatureCheck == SignatureCheckResult.SignatureBroken)
            {
                //Console.WriteLine("Signature of the message is either broken or forged");
                return(false);
            }
            else if (signatureCheck == SignatureCheckResult.PublicKeyNotMatching)
            {
                //   Console.WriteLine("The provided public key doesn't match the signature");
                return(false);
            }
            else if (signatureCheck == SignatureCheckResult.NoSignatureFound)
            {
                //  Console.WriteLine("This message is not digitally signed");
                return(false);
            }
            return(false);
        }
Esempio n. 2
0
        public void Decreypt(string encrypt)
        {
            //Get Public File
            GetKey  objKey     = new GetKey();
            int     ID         = Convert.ToInt32(Session["ID"].ToString());
            DataRow drKey      = objKey.drSearchStudentKey(ID);
            string  PublicKey1 = drKey[0].ToString();



            // obtain an OpenPGP signed message
            String signedString = encrypt;

            // Extract the message and check the validity of the signature
            String plainText;

            // create an instance of the library
            PGPLib pgp = new PGPLib();

            //SignatureCheckResult signatureCheck = pgp.VerifyString(signedString,
            //                                        new FileInfo(@"C:\Users\Dua'a-Orcas\Desktop\finalProject\WebApplication1 - Copy (2)\WebApplication1\Sig\public_key_exported.asc"),
            //                                        out plainText);


            SignatureCheckResult signatureCheck = pgp.VerifyString(signedString,
                                                                   new FileInfo(PublicKey1), out plainText);


            string strData1 = plainText;

            // Print the results
            Console.WriteLine("Extracted plain text message is " + plainText);
            if (signatureCheck == SignatureCheckResult.SignatureVerified)
            {
                Console.WriteLine("Signature OK");
                Result = true;
            }
            else if (signatureCheck == SignatureCheckResult.SignatureBroken)
            {
                Console.WriteLine("Signature of the message is either broken or forged");
            }
            else if (signatureCheck == SignatureCheckResult.PublicKeyNotMatching)
            {
                Console.WriteLine("The provided public key doesn't match the signature");
            }
            else if (signatureCheck == SignatureCheckResult.NoSignatureFound)
            {
                Console.WriteLine("This message is not digitally signed");
            }
        }
Esempio n. 3
0
        protected void btnSave_Click(object sender, EventArgs e)

        {
            int               ID       = Convert.ToInt32(Session["ID"].ToString());
            string            password = txtPassword.Text.ToString();
            string            Email    = labEmail.Text.ToString();
            SignatureStudents objj     = new SignatureStudents();

            objj.CreateSignature(password, Email, ID);
            string pathPub = System.Web.HttpContext.Current.Server.MapPath("../PageStudents/Sig") + "/" + ID + ".asc";

            string PrivateKey = "Sig/" + ID + "pr" + ".asc";
            GetKey objKey     = new GetKey();

            objKey.AddKeyStudent(pathPub, ID);
            downloadfile(PrivateKey);
        }
Esempio n. 4
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            int      ID           = Convert.ToInt32(Session["ID"].ToString());
            Studnets loginStudent = new Studnets();
            DataRow  loginS       = loginStudent.drSearchStudentEmail(ID);
            string   password     = null;
            string   Email        = null;

            if (loginS != null)
            {
                password = loginS["Password"].ToString();
                Email    = loginS["Email"].ToString();
            }
            //string password ="******";
            //string Email = "duaa.tan @gmail.com";
            CreateSignature(password, Email, ID);
            string PublicKey  = "C:/Users/Dua'a-Orcas/Desktop/WebApplication1/WebApplication1/WebApplication1/PageStudents/Sig/" + ID + ".asc";
            string PrivateKey = "Sig/" + ID + "pr" + ".asc";
            string PublicKey1 = "Sig/" + ID + ".asc";
            GetKey objKey     = new GetKey();

            objKey.AddKeyStudent(PublicKey, ID);
            downloadfile(PrivateKey);
        }