-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
52 lines (46 loc) · 1.52 KB
/
Program.cs
File metadata and controls
52 lines (46 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.IO.Pipes;
using System.Security.Principal;
using System.Diagnostics;
using System.Threading;
using Microsoft.Win32;
using CSP.RSA.Cipher;
namespace PipeClient
{
class Program
{
static void Main(string[] args)
{
NamedPipeClientStream pipeClient = new NamedPipeClientStream(".","testpipe",
PipeDirection.InOut, PipeOptions.None);
RSAChiper rsa;
if (pipeClient.IsConnected != true) { pipeClient.Connect(); }
StreamReader sr = new StreamReader(pipeClient);
StreamWriter sw = new StreamWriter(pipeClient);
string temp;
temp = sr.ReadLine();
if (temp == "Waiting")
{
try
{
sw.WriteLine("Connected");
sw.Flush();
pipeClient.WaitForPipeDrain();
temp = sr.ReadLine();
rsa = new RSAChiper(temp);
Console.WriteLine("Enviar datos:");
string texto=Console.ReadLine();
sw.WriteLine(rsa.RSAEncrypt(texto));
sw.Flush();
pipeClient.WaitForPipeDrain();
}
catch (Exception ex) { throw ex; }
}
pipeClient.Close();
}
}
}