コード例 #1
0
        protected void btnGet_Click(object sender, EventArgs e)
        {
            string    query = "SELECT * FROM KatKeep_Sites WHERE site_name = @sitename AND user_id = @userid";
            DataTable dt    = new DataTable();

            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["KatKeep"].ConnectionString))
            {
                using (SqlCommand cmd = new SqlCommand(query, sqlCon))
                {
                    try
                    {
                        sqlCon.Open();
                        cmd.Parameters.AddWithValue("@sitename", ddlSites.SelectedValue.ToString());
                        cmd.Parameters.AddWithValue("@userid", Session["userid"]);
                        using (SqlDataAdapter a = new SqlDataAdapter(cmd))
                        {
                            a.Fill(dt);
                        }
                    }
                    catch (Exception ex)
                    {
                        lblNotes.Text = "SITE NOT FOUND!";
                    }
                    NallCrypt nc = new NallCrypt();
                    foreach (DataRow row in dt.Rows)
                    {
                        lblSiteName.Text      = row[1].ToString();
                        hlSiteUrl.NavigateUrl = row[2].ToString();
                        hlSiteUrl.Text        = row[2].ToString();
                        lblUsername.Text      = row[3].ToString();
                        lblPassword.Text      = nc.Decrypt(row[4].ToString());
                        lblNotes.Text         = row[5].ToString();
                    }
                }
            }
        }
コード例 #2
0
        public bool CheckPass(string unencrypted_password, string userid)
        {
            NallCrypt nc    = new NallCrypt();
            bool      match = false;

            using (SqlConnection sqlCon = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["KatKeep"].ConnectionString))
            {
                string query = "SELECT pword from KatKeep_Login WHERE id=@userid";

                using (SqlCommand cmd = new SqlCommand(query, sqlCon))
                {
                    cmd.Parameters.AddWithValue("@userid", userid);
                    try
                    {
                        sqlCon.Open();
                        var result = cmd.ExecuteScalar();
                        if (result != null)
                        {
                            if (nc.Decrypt(result.ToString()) == unencrypted_password)
                            {
                                match = true;
                            }
                            else
                            {
                                match = false;
                            }
                        }
                    }
                    catch (Exception ex)
                    {
                        match = false;
                    }
                }
            }
            return(match);
        }
コード例 #3
0
ファイル: Admin.aspx.cs プロジェクト: nallware/IoT_HomeCtrl
        protected void btnEncDec_Click(object sender, EventArgs e)
        {
            string    plaintext;
            string    encryptedtext;
            NallCrypt nc = new NallCrypt();

            if (tbEncrypted.Text != "") //encrypted to text
            {
                plaintext = nc.Decrypt(tbEncrypted.Text);
                if (plaintext == "")
                {
                    DisplayUserMessage("Error!", "An error has occurred...", "Text failed to decrypt.  Bad encryption string.");
                }
                else
                {
                    DisplayUserMessage("Information", "Your decrypted string", "The text was able to decrypt successfully.  The decrypted text is: <span style=\"color: red;\">" + plaintext + "</span>.");
                }
            }
            else //text to encrypted
            {
                encryptedtext = nc.Encrypt(tbDecrypted.Text);
                DisplayUserMessage("Information", "Encryption", "The text was able to encrypt successfully.  The encrypted text is: <span style=\"color: red;\">" + encryptedtext + "</span>.");
            }
        }