//encryption
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO;
namespace LabMaster { public partial class encryption : Form { public encryption() { InitializeComponent(); }
int p = 0; float b; char t;
private void btns_Click(object sender, EventArgs e) {
string str = txts.Text.Trim();
string[] s = new string[str.Length]; s = str.Split(' '); string we = ""; char[] c = new char[str.Length]; for (int k = 0; k < s.Length; k++) {
string q = s[k]; for (int j = 0; j < q.Length; j++) { c = q.ToCharArray(); int a = (int)c[j]; //mathamatical a = a + 25500; //assign if (a % 2 == 0) a = a + 202; else a = a + 200; //bitwise conversion if (p == k) { b = a / 255; System.Math.Floor(b); t = (char)b; we = we + t.ToString(); a = a % 255; t = (char)a; we = we + t.ToString();
} else { we = we + " "; b = a / 255; System.Math.Floor(b); t = (char)b; we = we + t.ToString(); a = a % 255; t = (char)a; we = we + t.ToString(); }
p = k; }
}
txts.Text = string .Empty ; txts.Text = we; FileStream f1 = new FileStream("E:\\LabMaster\\LabMaster\\folders\\a.txt", FileMode.Truncate, FileAccess.Write); StreamWriter w = new StreamWriter(f1); w.Write(we); w.Flush(); w.Close(); f1.Close(); } } }
//Decryption
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; using System.Drawing; using System.Text; using System.Windows.Forms; using System.IO;
namespace LabMaster { public partial class decryption : Form { int t; int r = 0; string add,we; public decryption() { InitializeComponent(); StreamReader sr = File.OpenText("E:\\LabMaster\\LabMaster\\folders\\a.txt"); while (sr.Peek() != -1) { string ina = sr.ReadLine(); add += ina; } char[] c = new char[add.Length]; string[] sre = add.Split(' '); int o = (sre.Length) ; for (int j = 0; j < o;j++ ) { int temp=0; string sd = sre[j]; c = sd.ToCharArray(); for (int i = 0; i < (c.Length - 1);i++ ) {
temp = 0; r = 0; r = (int)c[i]; i = i + 1;
t = (int)c[i];
//bit converction r = (r * 255) + t; temp = temp + r; if (i==1 || i % 2 == 1) { r = r - 25500; if (r % 2 == 0) { r = r - 202;
char ew = (char)r; we = we + ew.ToString(); } else { r = r - 200;
char ew = (char)r; we = we + ew.ToString(); } } } we = we + " "; } txtc.Text = we; FileStream f1 = new FileStream("E:\\LabMaster\\LabMaster\\folders\\a1.txt", FileMode.Truncate, FileAccess.Write); StreamWriter w = new StreamWriter(f1); w.Write(we); w.Flush(); w.Close(); f1.Close(); } } }
|
No responses found. Be the first to respond and make money from revenue sharing program.
|