protected void SetPassword(string password) { //password = "******"; MyMD5 myMd5 = new MyMD5(); var md5 = myMd5.GetMd5ArrFromString(password); switch (_mKeyLength) { case 8: _mKey = new byte[8]; byte[] b = md5.SelectMany(BitConverter.GetBytes).ToArray(); for (int i = 8; i < b.Length; ++i) _mKey[i-8] = b[i]; break; case 16: _mKey = new byte[16]; md5.SelectMany(BitConverter.GetBytes).ToArray().CopyTo(_mKey, 0); break; case 32: _mKey = new byte[32]; md5.SelectMany(BitConverter.GetBytes).ToArray().CopyTo(_mKey, 0); myMd5.GetMd5ArrFromString(myMd5.GetMd5FromString(password)).SelectMany(BitConverter.GetBytes).ToArray().CopyTo(_mKey, 16); break; } //Encrypt("C:\\Users\\Boday-Alfaro\\Desktop\\SecurityShlikhutkaLab3.docx", "C:\\Users\\Boday-Alfaro\\Desktop\\2.docx"); //Decrypt("C:\\Users\\Boday-Alfaro\\Desktop\\2.docx", "C:\\Users\\Boday-Alfaro\\Desktop\\3.docx"); // Encrypt("C:\\Users\\Boday-Alfaro\\Desktop\\qwe1.txt", "C:\\Users\\Boday-Alfaro\\Desktop\\qwe2.txt"); // Decrypt("C:\\Users\\Boday-Alfaro\\Desktop\\qwe2.txt", "C:\\Users\\Boday-Alfaro\\Desktop\\qwe3.txt"); //MessageBox.Show("done"); }
public override void SetPassword(string password) { password = "******"; MyMD5 myMd5 = new MyMD5(); var md5 = myMd5.GetMd5ArrFromString(password); _mKey = md5.SelectMany(BitConverter.GetBytes).ToArray(); _mPasswordMd5 = _mKey; Encrypt("C:\\Users\\Boday-Alfaro\\Desktop\\MpShlikhutkaLab4.docx", "C:\\Users\\Boday-Alfaro\\Desktop\\qwe1"); Decrypt("C:\\Users\\Boday-Alfaro\\Desktop\\qwe1", "C:\\Users\\Boday-Alfaro\\Desktop\\qwe1.docx"); MessageBox.Show("done"); }