using System; using System.Text; using System.Windows; using System.Windows.Input; using System.Security.Cryptography; namespace SicUI { /// /// WinDataView.xaml 的交互逻辑 /// public partial class EditorPassCheckView : Window { private string _sPassword = ""; public EditorPassCheckView() { } // public string Password { get { return _sPassword; } set { _sPassword = value; } } public EditorPassCheckView(Object obj) { InitializeComponent(); // txtPass.Focus(); } private void Button_Click(object sender, RoutedEventArgs e) { ToCheck(); } private void ToCheck() { var sPassword = txtPass.Password; if (sPassword.Length > 0) { if (CheckPass(sPassword)) { DialogResult = true; Close(); } else { MessageBox.Show("Password incorrect!","Error", MessageBoxButton.OK, MessageBoxImage.Error); } } else { MessageBox.Show("Please input password!","Error", MessageBoxButton.OK, MessageBoxImage.Error); } } private bool CheckPass(string sPassword) { MD5 m = MD5.Create(); byte[] bPass = Encoding.UTF8.GetBytes(sPassword); byte[] md5bPass = m.ComputeHash(bPass); string sPass = ""; for(int i=0;i