C # basic notes (14th days ),
1. MD5 Encryption
The user needs to re-encrypt the data inventory password. This process is called MD5 encryption.
As long as the password of the user involved must be encrypted with MD5
Generally, the MD5 password is in hexadecimal format.
The process of converting a password into a hexadecimal format is called MD5 encryption.
The process of encrypting a string into MD5 is irreversible. You can only change the string to the MD5 value, but not the MD5 value to the string.
However, someone has simulated the MD5 encryption process and written a set of algorithms for decryption. But it cannot be the same as encryption, but some simple ones can be solved, such as 123.
But it cannot be decrypted if it is more complex.
Exercise encryption 123 MD5: 202cb962ac59075b964b07152d234b70
Shift + alt + f10 namespace
Byte array-three methods are required for string theory
1. parse each element in the byte array into a string according to the specified encoding format
2. directly convert the array ToString ();
3. ToString () for each element in the byte array ();
. ToString ("x") converts decimal to hexadecimal
The content in ToString ("") can be converted to the format. Check if necessary.
Static void Main (string [] args)
{
// MD5: 202cb962ac59075b964b07152d234b70
// X2: 202cb962ac59075b964b07152d234b70
// X: 202cb962ac5975b964b7152d234b70
// 3244185981728979115075721453575112 (decimal) --- convert to hexadecimal
String s = getmd5. ("123 ");
Console. WriteLine (s );
Console. ReadKey ();
}
Public static string GetMD5 (string str)
{
// Create an MD5 object
MD5 md5 = MD5.Create ();
// Start Encryption
// Convert the string to a character array
Byte [] buffer = Encoding. GetEncoding ("GBK"). GetBytes (str );
// Returns an encrypted byte array.
Byte [] MD5Buffer = md5.ComputeHash (buffer );
// Convert the byte array into a string
// The output is garbled (encoding can be ruled out)
// The first four lines of code will not have any problems
// The problem lies in the following line. What we need is hexadecimal.
// Byte array --- three methods are required for string theory
// Parse each element in the byte array into a string according to the specified encoding format
// Directly convert the array ToString (); (PASS, because direct conversion is the namespace)
// ToString () for each element in the byte array ();
// Return Encoding. GetEncoding ("GBK"). GetString (MD5Buffer );
// 189 275 345 I LOVE YOU (PASS)
// 189 275 345 189275345
String strNew = "";
For (int I = 0; I <MD5Buffer. Length; I ++)
{
StrNew + = MD5Buffer [I]. ToString ("x2 ");
}
Return strNew;
2. desktop applications
1. The winform application is a Smart Client technology. We can use the winform application to help us obtain or transmit information.
Asp and asp.net are not one thing. asp is outdated.
What winform applications learn is Tora.
The XAML language is used for winform UI.
When form1.designer. cs window is designed, the compiler automatically generates code
Form1.resx resource file
Form1 background code
Still operating form1.cs
2. Attributes
Name: to obtain the foreground space object in the background, you must use the Name attribute.
Visible: Indicates whether a control is visible.
Enabled: Indicates whether a control is available.
3. Event: an event occurs.
Registration event: double-click the control to register the selected event by default.
Trigger event:
F4 registration event
4,
The form object created in the Main function is called the Main form of the form application.
This means that when you close the main form, the entire application is closed.
3.
Public partial class Form1: Form
{
Public Form1 ()
{
InitializeComponent ();
}
Private void button#click (object sender, EventArgs e)
{
MessageBox. Show ("I love you too, too ");
This. Close (); // Close the main form
}
Private void button2_MouseEnter (object sender, EventArgs e)
{
// Give the button a new coordinate
// The maximum width of the button activity is the width of the form minus the width of the button
Int x = this. ClientSize. Width-button2.Width;
Int y = this. ClientSize. Height-button2.Height;
Random r = new Random ();
// Give the button a random Coordinate
Button2.Location = new Point (r. Next (0, x + 1), r. Next (0, y + 1 ));
}
Private void button2_Click (object sender, EventArgs e)
{
MessageBox. Show ("You have clicked it ");
This. Close ();
}
5. TextBox Control
WorWrap: Indicates whether to wrap the text box.
PassWordChar: display a single character in the text box
ScollBars: whether to display the scroll bar
Event: TextChanged: this event is triggered when the content in the text box changes.
4. Timer
Abcde
Bcdea
String str = "abcde ";
Str = str. substring (1) + str. substring (0, 1 );
6. Timer
Perform a specified task within the specified time interval.
5. Simple notes for this application
1) when the program loads the text box, cancel the automatic line feed of the text box, and hide the two buttons and text box.
2) Click "Log on" to check whether the logon is successful.
3) automatic line feed
4) Save the text to the specified directory.
7. multiple-choice and single-choice controls
Public controls
CheckBox Square
RadioButton circle (optional)
Container
GroupBox multiple-choice set
Single choice and multiple choice
Checked: indicates whether the control is selected.
By default, only one single button can be selected in a form. groupbox can be used for grouping.
You can select multiple groups.
8. Design of the MDI form
1. First, determine a parent form to set IsMdiContainer to true.
Create a child form-menu and toolbar-MenuStrip
2. Create child forms and set their parent forms.
LayoutMdi (MdiLayout. TileHorizontal) horizontal arrangement
LayoutMdi (MdiLayout. TileVertical) Vertical arrangement
9. PictureBox
PictureBox1.Image = Image. FromFile (@ "Image path ");
Path
File Operation file
Directory operation Directory. GetFiles (@ "folder path ")
// Set how the image is displayed in PictureBox1
PictureBox1.SizeMode = PictureBoxSizeMode. StretchImage;