-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram.cs
More file actions
70 lines (58 loc) · 1.47 KB
/
Program.cs
File metadata and controls
70 lines (58 loc) · 1.47 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
70
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace IniPlusPlus {
class Program {
static void Main(string[] args) {
byte[] loadFile = new byte[File.ReadAllBytes(args[0]).Length];
loadFile = File.ReadAllBytes(args[0]);
byte[] stringFile;
stringFile = Encrypt(loadFile, args[2]);
File.WriteAllBytes(args[1], stringFile);
}
private static byte[] Encrypt(byte[] data, string key) {
int STRSIZE = 256;
int[] v11 = new int[STRSIZE];
int[] v6 = new int[STRSIZE];
int v7 = 0;
int v10;
int v12;
int v5;
int pos2 = 0;
byte[] returnVar = new byte[data.Length];
for (int pos = 0; pos < STRSIZE; pos++) {
v11[pos] = pos;
}
if (key != null) {
for (int pos = 0; pos < STRSIZE; pos++) {
if (v7 == key.Length)
v7 = 0;
v6[pos] = key[v7];
v7++;
}
}
v7 = 0;
for (int pos = 0; pos < STRSIZE; pos++) {
v7 = (v6[pos] + v11[pos] + v7) % 256;
v10 = v11[pos];
v11[pos] = v11[v7];
v11[v7] = v10;
}
v7 = 0;
for (int pos = 0; pos < data.Length; pos++) {
pos2 = (pos2 + 1) % 256;
v7 = (v7 + v11[pos2]) % 256;
v10 = v11[pos2];
v11[pos2] = v11[v7];
v11[v7] = v10;
v12 = (v11[v7] + v11[pos2]) % 256;
v5 = v11[v12];
returnVar[pos] = Convert.ToByte(data[pos] ^ (v5));
}
return returnVar;
}
}
}