- 浏览: 139532 次
文章分类
最新评论
c# wpf 加密文本
可以加密人们的内容,文本加密。
界面
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:System="clr-namespace:System;assembly=mscorlib" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="encryption_note.MainWindow"
Height="700" Width="405.8" Icon="/resources/bitbug_favicon.ico" WindowStartupLocation="CenterScreen" Title="密码本" Unloaded="exit_button">
<Grid x:Name="formMain" KeyDown="fastkey">
<Grid.RowDefinitions>
<RowDefinition Height="20*"/>
<RowDefinition Height="650*"/>
</Grid.RowDefinitions>
<Grid Grid.Row="0">
<Menu>
<MenuItem Header="文件(_F)">
<MenuItem Header="新建(_N)" Click="new_file_button" >
</MenuItem>
<MenuItem Header="打开(_O)" Click="open_button" >
</MenuItem>
<MenuItem Header="保存(_S)" Click="save_button" IsEnabled="{Binding Path=main_enable,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
</MenuItem>
<MenuItem Header="另存为(_A)" Click="save_as_button" IsEnabled="{Binding Path=main_enable,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
</MenuItem>
<MenuItem Header="退出(_X)" Click="exit_button" >
</MenuItem>
</MenuItem>
<MenuItem Header="编辑(_E)">
<MenuItem Header="全选(_A)" Click="select_button" IsEnabled="{Binding Path=main_enable,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
</MenuItem>
<MenuItem Header="复制(_C)" Click="copy_button" IsEnabled="{Binding Path=main_enable,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
</MenuItem>
<MenuItem Header="粘贴(_V)" Click="paste_button" IsEnabled="{Binding Path=main_enable,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}">
</MenuItem>
</MenuItem>
<MenuItem Header="帮助(_H)">
<MenuItem Header="关于(_A)" >
</MenuItem>
</MenuItem>
</Menu>
</Grid>
<Grid Grid.Row="1">
<Grid x:Name="registerGrid" Visibility="{Binding Path=register_visibility,Mode=OneWay}" Background="#FF130464" d:IsHidden="True">
<StackPanel Orientation="Vertical">
<Label x:Name="reminder" HorizontalAlignment="Left" Height="35" Margin="10,270,0,0" Content="{Binding Path=reminder_content,Mode=OneWay}" VerticalAlignment="Top" Width="379" Background="{x:Null}" FontSize="20" BorderBrush="{x:Null}" Foreground="#FFF6F9F7"/>
<PasswordBox x:Name="codeIn" Visibility="{Binding Path=codein_visibility,Mode=OneWay}" HorizontalAlignment="Center" Margin="0" VerticalAlignment="Center" FontSize="26.667" Width="383.335" ToolTip="密码大于10字符"/>
<Button x:Name="registerButton" Content="确定" HorizontalAlignment="Right" Height="33.875" Margin="10,10,10,10" VerticalAlignment="Center" Width="69.633" IsDefault="True" Click="registerButtonClick" />
</StackPanel>
<ProgressBar x:Name="progressBar" Visibility="{Binding Path=progress_bar_visibility,Mode=OneWay,UpdateSourceTrigger=PropertyChanged}" IsIndeterminate="True" Height="50" d:IsHidden="True" />
<!--输入密码password_box-->
</Grid>
<Grid x:Name="mainGrid" Visibility="{Binding Path=main_visibility,Mode=OneWay}">
<!--显示密码text-->
<TextBox x:Name="source" Margin="0,0,0,0" TextWrapping="Wrap" Text="{Binding Path=text_string, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" TextOptions.TextFormattingMode="Display" ScrollViewer.CanContentScroll="True" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" LostFocus="source_lostfocus"/>
</Grid>
</Grid>
</Grid>
</Window>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace encryption_note
{
/// <summary>
/// MainWindow.xaml 的交互逻辑
/// </summary>
public partial class MainWindow : Window
{
ViewModel view_model = ViewModel.g_view_model();
public MainWindow()
{
InitializeComponent();
this.DataContext = ViewModel.g_view_model();
codeIn.Focus();
}
private void registerButtonClick(object sender , RoutedEventArgs e)
{
progressBar.Visibility = Visibility.Visible;
view_model.register_button_click(codeIn.Password);
codeIn.Password = "";
progressBar.Visibility = Visibility.Hidden;
}
/// <summary>
/// 没焦点,保存
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
private void source_lostfocus(object sender, RoutedEventArgs e)
{
view_model.new_key();
}
private void save_button(object sender, RoutedEventArgs e)
{
view_model.new_key();
}
private void open_button(object sender, RoutedEventArgs e)
{
view_model.open_file();
codeIn.Focus();
}
private void new_file_button(object sender, RoutedEventArgs e)
{
view_model.new_file();
}
private void save_as_button(object sender, RoutedEventArgs e)
{
view_model.save_file();
}
private void exit_button(object sender, RoutedEventArgs e)
{
view_model.new_key();
Application.Current.Shutdown();
}
private void select_button(object sender, RoutedEventArgs e)
{
source.Focus();
source.SelectAll();
}
private void copy_button(object sender, RoutedEventArgs e)
{
Clipboard.SetText(source.SelectedText);
}
private void paste_button(object sender, RoutedEventArgs e)
{
string temp;
temp = source.Text.Substring(source.SelectionStart);
source.Text = source.Text.Substring(0, source.SelectionStart) + Clipboard.GetText() + temp;
}
private void fastkey(object sender , KeyEventArgs e)
{
if ((Keyboard.Modifiers & ModifierKeys.Control) == ModifierKeys.Control)
{
switch (e.Key)
{
case Key.N:
new_file_button(sender , new RoutedEventArgs());
break;
case Key.S:
save_button(sender , new RoutedEventArgs());
break;
case Key.O:
open_button(sender , new RoutedEventArgs());
break;
default:
break;
}
}
if(e.Key==Key.Escape)
{
exit_button(sender , new RoutedEventArgs());
}
}
}
}
把界面的数据绑定
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace encryption_note
{
public class ViewModel : INotifyPropertyChanged
{
mul_key_encryption mul_key = new mul_key_encryption();
private ViewModel()
{
first = true;
if (File.Exists(mul_key.file_address))
{
first = false;
reminder_content = "请输入密码";
}
else
{
first = true;
reminder_content = "第一次使用,请输入密码";
}
register_visibility = Visibility.Visible;
main_visibility = Visibility.Hidden;
//progress_bar_visibility = Visibility.Hidden;
register = true;
}
public event PropertyChangedEventHandler PropertyChanged;
public Visibility register_visibility
{
set
{
if (value == Visibility.Visible)
{
_register_visibility = true;
}
else if (value == Visibility.Hidden)
{
_register_visibility = false;
}
OnPropertyChanged("register_visibility");
}
get
{
if (_register_visibility == true)
{
return Visibility.Visible;
}
else
{
return Visibility.Hidden;
}
}
}
public Visibility main_visibility
{
set
{
if (value == Visibility.Visible)
{
_main_visibility = true;
}
else if (value == Visibility.Hidden)
{
_main_visibility = false;
}
OnPropertyChanged("main_visibility");
OnPropertyChanged("main_enable");
}
get
{
if (_main_visibility == true)
{
return Visibility.Visible;
}
else
{
return Visibility.Hidden;
}
}
}
public bool main_enable
{
set
{
_main_visibility = value;
}
get
{
return _main_visibility;
}
}
public Visibility progress_bar_visibility
{
set
{
if (value == Visibility.Visible)
{
register = false;
}
else
{
register = true;
}
OnPropertyChanged("password_box_visibility");
}
get
{
if (register == true)
{
return Visibility.Hidden;
}
else
{
return Visibility.Visible;
}
}
}
public Visibility codein_visibility
{
set
{
if (value == Visibility.Visible)
{
register = true;
}
else
{
register = true;
}
OnPropertyChanged("codein_visibility");
}
get
{
if (register == true)
{
return Visibility.Visible;
}
else
{
return Visibility.Hidden;
}
}
}
public string text_string
{
set
{
_text_string.Clear();
_text_string.Append(value);
OnPropertyChanged("text_string");
}
get
{
return _text_string.ToString();
}
}
public string reminder_content
{
set
{
_reminder_content.Clear();
_reminder_content.Append(value);
OnPropertyChanged("reminder_content");
}
get
{
return _reminder_content.ToString();
}
}
/// <summary>
/// true 输入,不进度条,false不输入,进度条
/// </summary>
public bool register
{
set
{
_register = value;
OnPropertyChanged("password_box_visibility");
OnPropertyChanged("codein_visibility");
}
get
{
return _register;
}
}
/// <summary>
/// 第一次使用
/// </summary>
public bool first
{
set
{
_first = value;
}
get
{
return _first;
}
}
/// <summary>
/// 进入密码
/// </summary>
public string key
{
set
{
_key = value;
}
get
{
return _key;
}
}
public static ViewModel g_view_model()
{
if (_view_model == null)
{
_view_model = new ViewModel();
}
return _view_model;
}
public void new_file()
{
//mul_key.new_use(key);
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "data";
dlg.DefaultExt = ".data";
dlg.Filter = "data(.data)|*.data";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
mul_key.file_address = dlg.FileName;
//mul_key.override_entryption(text_string);
first = true;
register_visibility = Visibility.Visible;
main_visibility = Visibility.Hidden;
register = true;
text_string = "";
}
}
public void open_file()
{
new_key();
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "data";
dlg.DefaultExt = ".data";
dlg.Filter = "data(.data)|*.data";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
mul_key.file_address = dlg.FileName;
first = false;
register_visibility = Visibility.Visible;
main_visibility = Visibility.Hidden;
register = true;
text_string = "";
}
}
/// <summary>
/// 另存为
/// </summary>
/// <param name="file_address">文件地址</param>
public void save_file()
{
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "data";
dlg.DefaultExt = ".data";
dlg.Filter = "data(.data)|*.data";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
mul_key.file_address = dlg.FileName;
mul_key.override_entryption(text_string);
}
}
/// <summary>
/// 显示密码
/// </summary>
public void calculate_key_txt()
{
StringBuilder str = new StringBuilder();
mul_key.jmz_decryption();
foreach (var temp in mul_key.file_key)
{
str.Append(temp);
}
text_string = str.ToString();
Debug.Write(str.ToString());
}
/// <summary>
/// 保存密码
/// </summary>
public void new_key()
{
//mul_key.new_entryption(text_string);
Debug.Write("保存\n");
if (main_visibility == Visibility.Visible)
{
mul_key.override_entryption(text_string);
}
}
public void register_button_click(string key)
{
Debug.Write("register\n");
register = false;
Debug.Write("key" + key + "\n");
//progress_bar_visibility = Visibility.Visible;
if (key.Length > 10 && key.Length < 500)
{
if (first == true)
{
//new_file(key);
mul_key.new_use(key);
register_visibility = Visibility.Hidden;
main_visibility = Visibility.Visible;
}
else
{
if (mul_key.confirm_password(key))
{
calculate_key_txt();
register_visibility = Visibility.Hidden;
main_visibility = Visibility.Visible;
}
else
{
reminder_content = "密码错误,请重新输入";
}
//Debug.Write("key" + key + "\n");
}
}
else
{
reminder_content = "密码长度必须大于10字符";
}
register = true;
}
private static ViewModel _view_model = new ViewModel();
private StringBuilder _text_string = new StringBuilder();
private StringBuilder _reminder_content = new StringBuilder();
private bool _first;
private bool _register;
private bool _register_visibility;
private bool _main_visibility;
private string _key;
protected void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this , new PropertyChangedEventArgs(name));
}
}
}
}
使用字符串加密类,有公共
属性 key:密码
file_address:文件地址
方法 n_md5(string key) :将key进行n md5,我是用字符串的第一个字符unicode作为n
encryption(string str):加密字符串
decryption(string str):揭秘字符串
using System;
using System.Diagnostics;
using System.Text;
namespace encryption_note
{
public class string_decryption
{
///需要 using System.IO;
private string_decryption()
{
file_address = @".\data.data";
_temp_string_lenth = 1024;
}
public string_decryption(string file_加密的文件 , int key_length_more512)
{
key_length_more512 = 1024;
_temp_string_lenth = key_length_more512;
file_address = file_加密的文件;
}
public string_decryption(string key)
{
int 密钥_大于512;
密钥_大于512 = 1024;
_temp_string_lenth = 密钥_大于512;
this.key = key;
}
public static string_decryption g_获得类()
{
return _string_decryption;
}
public static string_decryption g_获得类(string file_加密的文件)
{
_string_decryption = new string_decryption(file_加密的文件 , 1024);
return _string_decryption;
}
~string_decryption()
{
}
public string key
{
get
{
if (_key.Length <= 0)
{
return "林德熙";
}
return _key;
}
set
{
_key = value;
}
}
/// <summary>
/// 加密文件绝对位置
/// </summary>
public string file_address
{
set
{
_file_address = value;
}
get
{
return _file_address;
}
}
private int ran
{
set
{
_random = new Random(value);
}
get
{
return _random.Next(2) == 0 ? _random.Next(19968 , 40864) : _random.Next(33 , 126);
}
}
public string encryption(string str)
{
char[] temp_str = new char[_temp_string_lenth];
int i , has , key_place;//has字符位置,key_place密码位置
//str = encryptDes(str);
str += "结束";
str.PadRight(_temp_string_lenth);
for (i = 0; i < _temp_string_lenth; i++)
{
temp_str[i] = Convert.ToChar(0);
}
key_place = 0;
for (i = 0; i < str.Length; i++)
{
has = Convert.ToInt32(key[key_place]);
has = has % _temp_string_lenth;
while (temp_str[has] != Convert.ToChar(0))//如果位置有别的字符就下一个,到没有字符位置
{
has++;
if (has >= _temp_string_lenth)
{
has = 0;
}
//has=has>=_temp_string_lenth?0:has++;
}
//temp_str[l] = (char)(str[i]);//+key[key_l]);
temp_str[has] = (char)((str[i]) + key[key_place]);
key_place++;
if (key_place == key.Length)
{
key_place = 0;
}
//key_place=key_place>=key.length?0:key_place++;
}
//把空填充
for (i = 0; i < _temp_string_lenth; i++)
{
if (temp_str[i] == Convert.ToChar(0))
{
temp_str[i] = Convert.ToChar(ran); //% 1000+1);
}
}
string s = new string(temp_str);
return s;
//return null;
}
public string decryption(string str)
{
StringBuilder temp = new StringBuilder();
char[] jie = str.ToCharArray();
int has , key_place;//has字符位置,key_place密码位置
bool accomplish;
accomplish = false;//初始
has = 0;
key_place = 0;
if (jie.Length < _temp_string_lenth - 1)
{
Debug.Write("错" + jie.Length.ToString());
return null;
}
while (accomplish == false)//我while(true)
{
has = Convert.ToInt32(key[key_place]);
has = has % _temp_string_lenth;//密码给字符所在位置
while (jie[has] == Convert.ToChar(0))
{
has++;
if (has >= _temp_string_lenth)
{
accomplish = true;
break;
}
}
if (accomplish)
{
break;
}
temp.Append((char)((jie[has]) - key[key_place]));
jie[has] = Convert.ToChar(0);//把原来位置0
key_place++;
if (key_place == key.Length)
{
key_place = 0;
}
}
string temp_str = temp.ToString();
int temp_l = temp_str.LastIndexOf("结束");
if (temp_l > 0)
{
return temp_str.Substring(0 , temp_l);
}
else
{
return null;
}
}
/// <summary>
/// 加密key[0].toint次md5
/// </summary>
/// <param name="key">密码</param>
/// <returns>加密后密码</returns>
public string n_md5(string key)
{
string temp;
int i;
int str_0_length;
if (string.IsNullOrEmpty(key))
{
temp = "";
return temp.PadRight(32 , '0');
}
str_0_length = Convert.ToInt32(key[0]);
temp = get_MD5(key);
for (i = 1; i < str_0_length; i++)
{
temp = get_MD5(temp);
}
return temp;
}
private int _temp_string_lenth;
private static string_decryption _string_decryption = new string_decryption();
private Random _random = new Random();
//加密文件的路径
private string _file_address;
private string _key;
/// <summary>
/// md5加密
/// </summary>
/// <param name="str">要加密字符串</param>
/// <returns>加密后密码</returns>
private string get_MD5(string str)
{
System.Security.Cryptography.MD5CryptoServiceProvider md5 = new System.Security.Cryptography.MD5CryptoServiceProvider();
byte[] temp;
StringBuilder strb = new StringBuilder();
temp = md5.ComputeHash(Encoding.Unicode.GetBytes(str));
md5.Clear();
for (int i = 0; i < temp.Length; i++)
{
strb.Append(temp[i].ToString("X").PadLeft(2 , '0'));
}
return strb.ToString().ToLower();
}
}
}
这是使用只是一个字符串的加密,而在字符串很长就不能。
我把一个很长的字符串分割为多个字符串。
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace encryption_note
{
public class mul_key_encryption
{
public mul_key_encryption()
{
new_class();
}
public mul_key_encryption(string key)
{
new_class(key);
}
~mul_key_encryption()
{
file_key.Clear();
decryption.Clear();
}
/// <summary>
/// 默认没有jia.key 密码
/// </summary>
public List<string> file_key
{
set
{
_key = value;
}
get
{
return _key;
}
}
public List<string> decryption
{
set
{
_decryption = value;
}
get
{
return _decryption;
}
}
public bool confirm_password(string key)
{
int len;
string temp;
len = 2048;
FileStream fs = new FileStream(file_address , FileMode.Open);
byte[] buffer = new byte[len];
fs.Read(buffer , 0 , len);//不密码
fs.Close();
temp = Encoding.Unicode.GetString(buffer);
jia.key = key;
return string.Equals(jia.n_md5(key) , jia.decryption(temp));
}
/// <summary>
/// 获得密码
/// </summary>
/// <returns>保存下密码</returns>
public string jmz_decryption()
{
string str;
str = "";
file_key.Clear();
d_scan();
foreach (string temp in decryption)
{
file_key.Add(jia.decryption(temp));
}
foreach (string temp in file_key)
{
str += temp + "\r\n\r\n";
}
return str;
}
/// <summary>
/// 要新增密码
/// </summary>
/// <param name="key">密码</param>
public void new_entryption(string key)
{
int sub = key.IndexOf("\r\n\r\n");
string temp;
while (sub != -1)
{
//如果开头\r\n\r\n那么直接去空
temp = key.Substring(0 , sub);
if (temp.Length > 0)
{
file_key.Add(temp);
}
key = key.Substring(sub + 4);
sub = key.IndexOf("\r\n\r\n");
}
file_key.Add(key);
//加密();
hold_decryption_key();
}
/// <summary>
/// 覆盖密码,把原有密码删掉
/// </summary>
/// <param name="key">密码</param>
public void override_entryption(string key)
{
file_key.Clear();//污染
while(key.Length>100)
{
file_key.Add(key.Substring(0, 100));
key = key.Substring(100);
}
file_key.Add(key);
hold_decryption_key();
}
public void new_use(string key)
{
jia.key = key;
file_key.Clear();
decryption.Clear();
hold_decryption_key();
//x_write();2015年5月12日19:55:57
}
/// <summary>
/// 删除密码
/// </summary>
/// <param name="key">要删除密码</param>
/// <returns>如果删除return true;如果没有return false</returns>
public bool delete_key(string key)
{
return file_key.Remove(key);
}
/// <summary>
///
/// </summary>
/// <param name="key">密码号</param>
/// <returns></returns>
public bool delete_key(int key)
{
if (key < file_key.Count)
{
file_key.RemoveAt(key);
return true;
}
return false;
}
private string_decryption jia
{
set
{
value = null;
}
get
{
return string_decryption.g_获得类();
}
}
private List<string> _key = new List<string>();
public string file_address
{
set
{
jia.file_address = value;
}
get
{
return jia.file_address;
}
}
private List<string> _decryption = new List<string>();
private bool new_class()
{
new_class("qq123456");
return true;
}
private bool new_class(string key)
{
file_address = @".\data.data";
jia.file_address = file_address;
jia.key = key;
return true;
}
/// <summary>
/// 写加密文件
/// </summary>
///<param name="str">函数要写入文件内容</param>
/// <returns>如果写成功返回true</returns>
private bool x_write()
{
FileStream xiaFile = new FileStream(file_address , FileMode.Create);
byte[] buf;
foreach (string temp in decryption)
{
buf = Encoding.Unicode.GetBytes(temp);
xiaFile.Write(buf , 0 , buf.Length);
}
decryption.Clear();
xiaFile.Flush();
xiaFile.Close();
return true;
}
/// <summary>
/// 读文件
/// </summary>
/// <param name="str">读文件内容保存到str</param>
/// <returns>读文件成功返回true</returns>
private bool d_scan()
{
string temp;
int len;//文件长
len = 2048;
decryption.Clear();//不污染
//文件流
try
{
FileStream fs = new FileStream(file_address , FileMode.Open);
//缓冲
byte[] buffer = new byte[len];
fs.Read(buffer , 0 , len);//不密码
while (fs.Read(buffer , 0 , len) != 0)
{
temp = Encoding.Unicode.GetString(buffer);
//没有解密
decryption.Add(temp);
}
//让文件可以被其他打开
fs.Close();
return true;
}
catch
{
//如果文件被占用,没有找到文件
return false;
}
}
/// <summary>
/// 添加、删除,可以保存密码
/// </summary>
private void hold_decryption_key()
{
//会污染
decryption.Clear();
//启动密码
decryption.Add(jia.encryption(jia.n_md5(jia.key)));
foreach (string temp in file_key)
{
if (temp != null && temp.Length > 0)
{
decryption.Add(jia.encryption(temp));
}
//如果密码空,不保存
}
x_write();
}
}
}
打开文件
Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
dlg.FileName = "data";
dlg.DefaultExt = ".data";
dlg.Filter = "data(.data)|*.data";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
//返回地址
}
保存文件
Microsoft.Win32.SaveFileDialog dlg = new Microsoft.Win32.SaveFileDialog();
dlg.FileName = "data";
dlg.DefaultExt = ".data";
dlg.Filter = "data(.data)|*.data";
Nullable<bool> result = dlg.ShowDialog();
if (result == true)
{
}
INotifyPropertyChanged
OnPropertyChanged(“属性”);
void OnPropertyChanged(string name)
{
PropertyChangedEventHandler handler = PropertyChanged;
if (handler != null)
{
handler(this , new PropertyChangedEventArgs(name));
}
}
public event PropertyChangedEventHandler PropertyChanged;
原本我的加密 http://blog.csdn.net/lindexi_gd/article/details/45419195
相关推荐
在本文中,我们将深入探讨如何使用C#编程语言在Windows Presentation Foundation(WPF)框架下实现类似QQ的功能。Visual Studio 2017是我们的开发环境,而.NET Framework 3.0或更高版本则提供了必要的支持。让我们...
这涉及到基础的UI设计,如使用Windows Forms或WPF(Windows Presentation Foundation)来构建用户界面,包括文本编辑框、菜单栏、按钮等元素。同时,需要编写事件处理程序,如点击“保存”按钮时触发的代码,实现...
《C#实现的加密图片文本网页录入记事本详解》 在当今信息化时代,个人信息安全日益受到重视,而一款能够记录文字、图片等多元信息并具有加密功能的记事本软件,无疑成为了日常生活和工作中不可或缺的工具。本文将...
本项目“C#文件加密及其播放器”显然关注的是如何使用C#实现文件的加密以及创建一个能解密并播放这些加密文件的播放器。这涉及到几个关键的技术点,包括文件操作、加密算法、播放器开发等。 首先,我们来探讨C#中的...
4. **事件处理**:当用户点击加密按钮时,C#程序会捕获该事件,读取输入框的文本,进行加密处理,然后将结果显示在另一个文本框中。解密过程类似,但需注意的是,解密前需要验证输入的密文是否有效,以及使用正确的...
C#中的Windows Forms或WPF框架是构建图形用户界面(GUI)的理想选择。在这个项目中,我们需要创建一个主窗口,它包含菜单栏、工具栏和状态栏。菜单栏可以设置常见的编辑操作,如新建、打开、保存、复制、粘贴等;...
【C#_WPF_PC_CSC_Reader】项目是一个基于C#编程语言,利用Windows Presentation Foundation(WPF)框架开发的个人计算机应用,主要用于读取智能卡(CSC,Card Smart Chip)上的数据。这个应用可能被设计为帮助用户与...
这个示例可能包括一个TextBox和一个虚拟键盘UI,当TextBox获得焦点时,虚拟键盘显示出来,用户可以通过点击屏幕上的按键输入文本。 **安全性考量** 虽然虚拟键盘增加了安全性,但并非万无一失。攻击者仍然可以通过...
在WPF中,这些元素可以通过XAML定义,如`TextBox`用于文本输入,`PasswordBox`用于安全的密码输入,`Button`用于触发登录操作。 4. **数据验证**: 在登录界面,数据验证至关重要。WPF提供了内置的数据验证机制,...
在创建聊天室时,我们可以使用WPF控件如TextBox(输入框)和TextBlock(显示文本)来构建聊天界面,并通过数据绑定将用户输入与后台逻辑关联起来。 接下来,我们使用C#来处理应用程序的逻辑。在多人聊天室中,你...
- **加密**:为保护文件内容,可以使用SSL/TLS或者自定义加密算法对传输的数据进行加密。 - **身份验证**:确保只有授权的用户才能访问和传输文件,可以采用用户名密码认证或证书认证。 7. **设计模式**: - **...
WPF提供了一种全新的方式来设计和开发用户界面,它集成了2D和3D图形、文本渲染、媒体播放、数据绑定、动画和样式等功能,为开发者提供了丰富的视觉效果和交互体验。 WPF的核心特性包括: 1. **XAML语言**:XAML是...
- 在C#中,我们可以使用Windows Forms或WPF创建图形用户界面(GUI)。对于聊天室,我们需要设计文本框让用户输入消息,按钮触发发送,以及一个文本控件显示接收到的聊天记录。 - GUI的更新需要在UI线程中进行,...
对于“CipherText”这个文件名,它可能代表了加密文本。在WPF中,如果目录包含加密内容,可能涉及到数据安全性和隐私保护。可以使用C#中的System.Security.Cryptography库来处理加密和解密操作。例如,AES(Advanced...
总的来说,这个"可以使用AES算法加密文档的记事本工程"结合了C#编程、WPF界面设计以及强大的AES加密技术,为用户提供了一个安全、便捷的文本编辑环境。无论是日常记事还是处理敏感信息,这款记事本都能提供可靠的...
- 虽然这个项目没有涉及图形用户界面(GUI),但在实际应用中,我们可能会使用Windows Forms或WPF来创建更友好的用户界面。不过,控制台程序可以作为理解基础逻辑的一个起点。 5. **注册与登录验证**: - 注册...
【局域网文件和文本传输工具(C#源码)】是一个基于C#编程语言开发的应用程序,专门设计用于在局域网内的两台计算机之间实现文件和文本的高效、安全传输。C#是一种强大的面向对象的编程语言,由微软公司开发,常用于...
综上所述,这款模拟抽奖系统WPF版展示了如何利用C#和WPF技术构建一个具有用户交互、数据处理和文件操作功能的桌面应用程序。开发者在实现过程中可以深入学习WPF的布局机制、数据绑定、事件处理以及文件I/O等关键技术...
WPF是.NET Framework的一部分,它提供了丰富的用户界面设计能力,包括2D和3D图形、动画、图像处理和文本渲染。WPF应用程序通常运行在桌面环境中,利用XAML(Extensible Application Markup Language)进行声明式编程...
**WPF屏幕键盘**是一种基于Windows Presentation Foundation (WPF)技术开发的应用程序,它为用户提供了一种在没有物理键盘的情况下输入文本的方式。这种技术对于触摸屏设备或者在特殊环境下需要虚拟键盘的情况尤其...