コード例 #1
0
        public static void newUser(string caption)
        {
            Form prompt = new Form();

            prompt.Width  = 320;
            prompt.Height = 210;
            prompt.Text   = caption;
            Label textLabel = new Label()
            {
                Left = 50, Top = 20, Text = "Username: "******"Password: "******"Ok", Left = 140, Width = 50, Top = 145
            };

            confirmation.Click += (sender, e) => {
                if (SqliteDataAccess.CheckIfUserExist(inputBox.Text))
                {
                    MessageBox.Show("User sudah terdaftar!", "Error", MessageBoxButtons.OK);
                }
                else
                {
                    SqliteDataAccess.newUser(new UserModel()
                    {
                        username = inputBox.Text,
                        password = EncryptPassword.Encrypt(inputBox2.Text, "zxc123")
                    });
                    prompt.Close();
                }
            };
            Button cancelBox = new Button()
            {
                Text = "Cancel", Left = 200, Width = 50, Top = 145
            };

            cancelBox.Click += (sender, e) =>
            {
                prompt.Close();
            };
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(inputBox);
            prompt.Controls.Add(textLabel2);
            prompt.Controls.Add(inputBox2);
            prompt.Controls.Add(cancelBox);
            prompt.ShowDialog();
        }
コード例 #2
0
 private static string GetDecryptedPassword(string user = "")
 {
     using (IDbConnection cnn = new SQLiteConnection(LoadConnectionString()))
     {
         var output = cnn.Query <UserModel>("SELECT * FROM User WHERE Username = '******'", new DynamicParameters());
         List <UserModel> listUser = output.ToList();
         UserModel        userModel;
         string           password = "";
         if (listUser.Count > 0)
         {
             userModel = listUser[0];
             password  = EncryptPassword.Decrypt(userModel.password, "zxc123");
         }
         return(password);
     }
 }
コード例 #3
0
        public static void changePassword(string text, string caption, string username)
        {
            Form prompt = new Form();

            prompt.Width  = 320;
            prompt.Height = 160;
            prompt.Text   = caption;
            Label textLabel = new Label()
            {
                Left = 50, Top = 20, Text = text, AutoSize = true
            };
            TextBox inputBox = new TextBox()
            {
                Left = 50, Top = 50, Width = 200
            };
            Button confirmation = new Button()
            {
                Text = "Ok", Left = 140, Width = 50, Top = 80
            };

            confirmation.Click += (sender, e) => {
                SqliteDataAccess.UpdatePassword(username, EncryptPassword.Encrypt(inputBox.Text, "zxc123"));
                prompt.Close();
            };
            Button cancelBox = new Button()
            {
                Text = "Cancel", Left = 200, Width = 50, Top = 80
            };

            cancelBox.Click += (sender, e) =>
            {
                prompt.Close();
            };
            prompt.Controls.Add(confirmation);
            prompt.Controls.Add(textLabel);
            prompt.Controls.Add(inputBox);
            prompt.Controls.Add(cancelBox);
            prompt.ShowDialog();
        }