Lib New
gacutil /if E:\ThirdParty\RockyLib\Rocky\bin\Release\Rocky.dll gacutil /u Rocky
partial class GmailForm { /// <summary> /// Required designer variable. /// </summary> private System.ComponentModel.IContainer components = null; /// <summary> /// Clean up any resources being used. /// </summary> /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param> protected override void Dispose(bool disposing) { if (disposing && (components != null)) { components.Dispose(); } base.Dispose(disposing); } #region Windows Form Designer generated code /// <summary> /// Required method for Designer support - do not modify /// the contents of this method with the code editor. /// </summary> private void InitializeComponent() { this.groupBox1 = new System.Windows.Forms.GroupBox(); this.button3 = new System.Windows.Forms.Button(); this.txtPwd = new System.Windows.Forms.TextBox(); this.button2 = new System.Windows.Forms.Button(); this.button1 = new System.Windows.Forms.Button(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.groupBox2 = new System.Windows.Forms.GroupBox(); this.button6 = new System.Windows.Forms.Button(); this.button5 = new System.Windows.Forms.Button(); this.button4 = new System.Windows.Forms.Button(); this.txtKey = new System.Windows.Forms.TextBox(); this.groupBox1.SuspendLayout(); this.groupBox2.SuspendLayout(); this.SuspendLayout(); // // groupBox1 // this.groupBox1.Controls.Add(this.button3); this.groupBox1.Controls.Add(this.txtPwd); this.groupBox1.Controls.Add(this.button2); this.groupBox1.Controls.Add(this.button1); this.groupBox1.Location = new System.Drawing.Point(12, 12); this.groupBox1.Name = "groupBox1"; this.groupBox1.Size = new System.Drawing.Size(200, 130); this.groupBox1.TabIndex = 0; this.groupBox1.TabStop = false; this.groupBox1.Text = "Encrypt"; // // button3 // this.button3.Location = new System.Drawing.Point(137, 99); this.button3.Name = "button3"; this.button3.Size = new System.Drawing.Size(55, 23); this.button3.TabIndex = 2; this.button3.Text = "Send"; this.button3.UseVisualStyleBackColor = true; this.button3.Click += new System.EventHandler(this.button3_Click); // // txtPwd // this.txtPwd.Location = new System.Drawing.Point(6, 20); this.txtPwd.Name = "txtPwd"; this.txtPwd.PasswordChar = '囧'; this.txtPwd.Size = new System.Drawing.Size(100, 21); this.txtPwd.TabIndex = 1; // // button2 // this.button2.Location = new System.Drawing.Point(6, 77); this.button2.Name = "button2"; this.button2.Size = new System.Drawing.Size(123, 23); this.button2.TabIndex = 1; this.button2.Text = "EncryptOutFilePath"; this.button2.UseVisualStyleBackColor = true; this.button2.Click += new System.EventHandler(this.button2_Click); // // button1 // this.button1.Location = new System.Drawing.Point(5, 48); this.button1.Name = "button1"; this.button1.Size = new System.Drawing.Size(124, 23); this.button1.TabIndex = 0; this.button1.Text = "EncryptInFilePath "; this.button1.UseVisualStyleBackColor = true; this.button1.Click += new System.EventHandler(this.button1_Click); // // openFileDialog1 // this.openFileDialog1.FileName = "openFileDialog1"; // // groupBox2 // this.groupBox2.Controls.Add(this.button6); this.groupBox2.Controls.Add(this.button5); this.groupBox2.Controls.Add(this.button4); this.groupBox2.Controls.Add(this.txtKey); this.groupBox2.Location = new System.Drawing.Point(12, 148); this.groupBox2.Name = "groupBox2"; this.groupBox2.Size = new System.Drawing.Size(200, 130); this.groupBox2.TabIndex = 2; this.groupBox2.TabStop = false; this.groupBox2.Text = "Decrypt"; // // button6 // this.button6.Location = new System.Drawing.Point(137, 101); this.button6.Name = "button6"; this.button6.Size = new System.Drawing.Size(55, 23); this.button6.TabIndex = 3; this.button6.Text = "Decrypt"; this.button6.UseVisualStyleBackColor = true; this.button6.Click += new System.EventHandler(this.button6_Click); // // button5 // this.button5.Location = new System.Drawing.Point(7, 78); this.button5.Name = "button5"; this.button5.Size = new System.Drawing.Size(122, 23); this.button5.TabIndex = 2; this.button5.Text = "DecryptOutFilePath"; this.button5.UseVisualStyleBackColor = true; this.button5.Click += new System.EventHandler(this.button5_Click); // // button4 // this.button4.Location = new System.Drawing.Point(7, 48); this.button4.Name = "button4"; this.button4.Size = new System.Drawing.Size(122, 23); this.button4.TabIndex = 1; this.button4.Text = "DecryptInFilePath "; this.button4.UseVisualStyleBackColor = true; this.button4.Click += new System.EventHandler(this.button4_Click); // // txtKey // this.txtKey.Location = new System.Drawing.Point(7, 20); this.txtKey.Name = "txtKey"; this.txtKey.Size = new System.Drawing.Size(100, 21); this.txtKey.TabIndex = 0; // // GmailForm // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F); this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font; this.ClientSize = new System.Drawing.Size(224, 291); this.Controls.Add(this.groupBox2); this.Controls.Add(this.groupBox1); this.Name = "GmailForm"; this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen; this.Text = "GmailHepler"; this.groupBox1.ResumeLayout(false); this.groupBox1.PerformLayout(); this.groupBox2.ResumeLayout(false); this.groupBox2.PerformLayout(); this.ResumeLayout(false); } #endregion private System.Windows.Forms.GroupBox groupBox1; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.OpenFileDialog openFileDialog1; private System.Windows.Forms.FolderBrowserDialog folderBrowserDialog1; private System.Windows.Forms.TextBox txtPwd; private System.Windows.Forms.GroupBox groupBox2; private System.Windows.Forms.TextBox txtKey; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button6; private System.Windows.Forms.Button button5; }
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.IO; using System.Linq; using System.Text; using System.Windows.Forms; using System.Net; namespace Rocky.App { public partial class GmailForm : Form { long splitLength = 1024L * 1024L * 20L; public GmailForm() { InitializeComponent(); } private void button1_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); } private void button2_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); } private void button3_Click(object sender, EventArgs e) { string inFilePath = openFileDialog1.FileName, outFolderPath = folderBrowserDialog1.SelectedPath; if (!string.IsNullOrEmpty(txtPwd.Text) && !string.IsNullOrEmpty(inFilePath) && !string.IsNullOrEmpty(outFolderPath)) { string fileName = Path.GetFileName(inFilePath); string encryptInFilePath = inFilePath, encryptOutFilePath = Path.Combine(outFolderPath, fileName); CryptoManaged c = new CryptoManaged(string.Empty); c.EncryptFile(encryptInFilePath, encryptOutFilePath, splitLength, SplitFileMode.InputFileLength); var gmail = new MailClient(); gmail.Config(MailClient.SystemMail.Gmail, txtPwd.Text); //gmail.Priority = System.Net.Mail.MailPriority.High; gmail.SetBody("Key 4 EncryptLib.", c.Key + "," + c.IV, Directory.GetFiles(outFolderPath, fileName + "_Part*.temp")); gmail.AddTo("ilovehaley.kid@gmail.com", string.Empty); try { txtPwd.ReadOnly = false; gmail.Send(); } catch (Exception ex) { MessageBox.Show(ex.Message); } finally { txtPwd.ReadOnly = true; Console.WriteLine("SendCompleted."); } } } private void button4_Click(object sender, EventArgs e) { openFileDialog1.ShowDialog(); } private void button5_Click(object sender, EventArgs e) { folderBrowserDialog1.ShowDialog(); } private void button6_Click(object sender, EventArgs e) { string inFilePath = openFileDialog1.FileName, outFolderPath = folderBrowserDialog1.SelectedPath; if (!string.IsNullOrEmpty(txtKey.Text) && !string.IsNullOrEmpty(inFilePath) && !string.IsNullOrEmpty(outFolderPath)) { string temp = Path.GetFileNameWithoutExtension(inFilePath); temp = temp.Remove(temp.IndexOf("_")); string fileName = temp + Path.GetExtension(inFilePath); string[] keys = txtKey.Text.Split(','); CryptoManaged c = new CryptoManaged(keys[0], keys[1]); string decryptOutFilePath = Path.Combine(outFolderPath, "D_" + fileName); c.DecryptFile(Path.GetDirectoryName(inFilePath) + fileName, decryptOutFilePath, splitLength, SplitFileMode.InputFileLength); } } } }