Advertisement
DelusionalCat

yup

Mar 19th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.54 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.Data;
  5. using System.Drawing;
  6. using System.IO;
  7. using System.Linq;
  8. using System.Security.Cryptography;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using System.Windows.Forms;
  12.  
  13. namespace programS_P3FISIERE
  14. {
  15. public partial class Form : System.Windows.Forms.Form
  16. {
  17. byte[] hash1;
  18. byte[] hash2;
  19. SHA512CryptoServiceProvider mySha512 = new SHA512CryptoServiceProvider();
  20.  
  21. public Form()
  22. {
  23. InitializeComponent();
  24. }
  25.  
  26. private void textBox1_TextChanged(object sender, EventArgs e)
  27. {
  28.  
  29. }
  30.  
  31. private void Check_files_Click(object sender, EventArgs e)
  32. {
  33. if (textBoxFile1Hash.Text.CompareTo(textBoxFile2Hash.Text) == 0)
  34. {
  35. MessageBox.Show("Fisierele sunt identice!", "Mesaj", MessageBoxButtons.OK);
  36. }
  37. else
  38. {
  39. MessageBox.Show("Fisierele NU sunt identice!", "Mesaj", MessageBoxButtons.OK);
  40. }
  41. }
  42.  
  43. private void openFileDialog1_FileOk(object sender, CancelEventArgs e)
  44. {
  45.  
  46. }
  47.  
  48. private void saveFileDialog2_FileOk(object sender, CancelEventArgs e)
  49. {
  50.  
  51. }
  52.  
  53.  
  54.  
  55.  
  56. public string ByteArrayToString(byte[] array)
  57. {
  58. return Encoding.ASCII.GetString(array);
  59. }
  60.  
  61.  
  62. /*
  63. private void File1_Click(object sender, EventArgs e)
  64. {
  65. OpenFileDialog f = new OpenFileDialog();
  66. if (f.ShowDialog() == DialogResult.OK)
  67. {
  68. string s = f.FileName;
  69. FileStream fstream = new FileStream(s, FileMode.Open);
  70. textBoxFile1.Text = s;
  71. hash1 = mySha512.ComputeHash(fstream);
  72. textBoxFile1Hash.Text = ByteArrayToString(hash1);
  73. fstream.Close();
  74. }
  75.  
  76. }
  77. */
  78. /*
  79. private void File2_Click(object sender, EventArgs e)
  80. {
  81. OpenFileDialog f = new OpenFileDialog();
  82. if (f.ShowDialog() == DialogResult.OK)
  83. {
  84. string s = f.FileName;
  85. FileStream fstream = new FileStream(s, FileMode.Open);
  86. textBoxFile2.Text = s;
  87. hash2 = mySha512.ComputeHash(fstream);
  88. textBoxFile2Hash.Text = ByteArrayToString(hash2);
  89. fstream.Close();
  90. }
  91. }
  92. */
  93. private void File1_Click_1(object sender, EventArgs e)
  94. {
  95. OpenFileDialog f = new OpenFileDialog();
  96. if (f.ShowDialog() == DialogResult.OK)
  97. {
  98. string s = f.FileName;
  99. FileStream fstream = new FileStream(s, FileMode.Open);
  100. textBoxFile1.Text = s;
  101. hash1 = mySha512.ComputeHash(fstream);
  102. textBoxFile1Hash.Text = ByteArrayToString(hash1);
  103. fstream.Close();
  104. }
  105. }
  106.  
  107. private void File2_Click(object sender, EventArgs e)
  108. {
  109. OpenFileDialog f = new OpenFileDialog();
  110. if (f.ShowDialog() == DialogResult.OK)
  111. {
  112. string s = f.FileName;
  113. FileStream fstream = new FileStream(s, FileMode.Open);
  114. textBoxFile2.Text = s;
  115. hash2 = mySha512.ComputeHash(fstream);
  116. textBoxFile2Hash.Text = ByteArrayToString(hash2);
  117. fstream.Close();
  118. }
  119. }
  120. }
  121. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement