示例#1
0
 protected void btnkey_Click(object sender, EventArgs e)
 {
     if (cls.IsExists("select * from uploadfileslist where UP_FileName='" + txtfilename.Text + "' ") == true)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                                             "alert('File Name Already exist. Choose A Different File Name.');", true);
         txtfilename.Text = "";
         return;
     }
     else
     {
         try
         {
             //string abcc= FileUpload1.PostedFile.FileName.;
             filename = txtfilename.Text;
             FileUpload1.SaveAs(Server.MapPath("~/all/base/") + filename);
             Passphrase = filename;
             System.Text.UTF8Encoding UTF8         = new System.Text.UTF8Encoding();
             MD5CryptoServiceProvider HashProvider = new MD5CryptoServiceProvider();
             byte[] TAESKey = HashProvider.ComputeHash(UTF8.GetBytes(Passphrase));
             TripleDESCryptoServiceProvider TAESAlgorithm = new TripleDESCryptoServiceProvider();
             TAESAlgorithm.Key     = TAESKey;
             TAESAlgorithm.Mode    = CipherMode.ECB;
             TAESAlgorithm.Padding = PaddingMode.PKCS7;
             byte[] DataToEncrypt = UTF8.GetBytes(filename);
             try
             {
                 ICryptoTransform Encryptor = TAESAlgorithm.CreateEncryptor();
                 Results = Encryptor.TransformFinalBlock(DataToEncrypt, 0, DataToEncrypt.Length);
             }
             finally
             {
                 TAESAlgorithm.Clear();
                 HashProvider.Clear();
                 AESKEy         = ak.Encrypt("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789");
                 AESKEy         = AESKEy.Substring(0, 16);
                 LTRPRIKEY.Text = AESKEy;
                 encryption();
                 matadata();
             }
         }
         catch (Exception ex)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                                                 "alert('" + ex + "');", true);
         }
     }
 }
示例#2
0
 protected void txtuseridname_TextChanged(object sender, EventArgs e)
 {
     try
     {
         if (cls.IsExists("select * from Registerlist where R_logid='" + txtuseridname.Text + "' ") == true)
         {
             ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                                                 "alert('UserId Already exist');", true);
             txtuseridname.Text = "";
         }
     }
     catch (Exception ex)
     {
         ScriptManager.RegisterStartupScript(this, this.GetType(), "popup",
                                             "alert(" + ex + ");", true);
     }
 }