-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathevenlydistributed-.cs
More file actions
69 lines (68 loc) · 2.22 KB
/
Copy pathevenlydistributed-.cs
File metadata and controls
69 lines (68 loc) · 2.22 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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
using System;
using System.Security.Cryptography;
using System.Text;
namespace EncFileCodec
{
internal class EncFileCodec
{
static void Main(string[] args)
{
//parseargs
List<string> argsnew = new List<string>();
for (int i = 0; i < args.Length; i++)
{
if (!args[i].Contains("\"")) argsnew.Add(args[i]);
else
{
string arg = args[i] + " ";
int j = 1;
while (true)
{
if (!args[i + j].Contains("\""))
{
arg += args[i + j] + " ";
}
else
{
arg += args[i + j];
break;
}
j++;
}
argsnew.Add(arg);
i += j;
}
}
args = argsnew.ToArray();
foreach (string arg in args)
{
FileStream fs = new(arg, FileMode.Open, FileAccess.Read);
FileStream encfsa = new(arg + "~1A", FileMode.OpenOrCreate, FileAccess.Write);
FileStream encfsb = new(arg + "~1B", FileMode.OpenOrCreate, FileAccess.Write);
bool is2 = false;
if (fs.Length % 2 == 0) is2 = true;
while (fs.Position < fs.Length - 2)
{
encfsa.WriteByte((byte)fs.ReadByte());
encfsb.WriteByte((byte)fs.ReadByte());
}
//
if (is2)
{
encfsa.WriteByte((byte)fs.ReadByte());
encfsb.WriteByte((byte)fs.ReadByte());
}
else
{
encfsa.WriteByte((byte)fs.ReadByte());
}
//
Console.WriteLine($"{arg} Done!");
fs.Dispose();
encfsa.Dispose();
encfsb.Dispose();
}
}
}
}