Skip to content

Commit a613bb8

Browse files
committed
Program to encrypt and decrypt custom map .info files for Onward 1.7
0 parents  commit a613bb8

4 files changed

Lines changed: 157 additions & 0 deletions

File tree

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.vs
2+
bin
3+
obj

CustomMapCracker.csproj

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<ImplicitUsings>enable</ImplicitUsings>
7+
<Nullable>enable</Nullable>
8+
</PropertyGroup>
9+
10+
</Project>

CustomMapCracker.sln

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 17
4+
VisualStudioVersion = 17.14.36221.1 d17.14
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CustomMapCracker", "CustomMapCracker.csproj", "{EE45DE83-315B-2825-B964-8DCBE7854B27}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{EE45DE83-315B-2825-B964-8DCBE7854B27}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{EE45DE83-315B-2825-B964-8DCBE7854B27}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{EE45DE83-315B-2825-B964-8DCBE7854B27}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{EE45DE83-315B-2825-B964-8DCBE7854B27}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {2EDBB646-6DB9-4048-A5AE-B6298CE7057E}
24+
EndGlobalSection
25+
EndGlobal

Program.cs

Lines changed: 119 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,119 @@
1+

2+
using System.Buffers.Text;
3+
using System.Text;
4+
5+
static string Rot13(string value)
6+
{
7+
int shift = 13;
8+
char[] array = value.ToCharArray();
9+
for (int i = 0; i < array.Length; i++)
10+
{
11+
int num = array[i];
12+
switch (num)
13+
{
14+
case 110:
15+
case 111:
16+
case 112:
17+
case 113:
18+
case 114:
19+
case 115:
20+
case 116:
21+
case 117:
22+
case 118:
23+
case 119:
24+
case 120:
25+
case 121:
26+
case 122:
27+
num -= shift;
28+
break;
29+
case 97:
30+
case 98:
31+
case 99:
32+
case 100:
33+
case 101:
34+
case 102:
35+
case 103:
36+
case 104:
37+
case 105:
38+
case 106:
39+
case 107:
40+
case 108:
41+
case 109:
42+
num += shift;
43+
break;
44+
default:
45+
switch (num)
46+
{
47+
case 78:
48+
case 79:
49+
case 80:
50+
case 81:
51+
case 82:
52+
case 83:
53+
case 84:
54+
case 85:
55+
case 86:
56+
case 87:
57+
case 88:
58+
case 89:
59+
case 90:
60+
num -= shift;
61+
break;
62+
case 65:
63+
case 66:
64+
case 67:
65+
case 68:
66+
case 69:
67+
case 70:
68+
case 71:
69+
case 72:
70+
case 73:
71+
case 74:
72+
case 75:
73+
case 76:
74+
case 77:
75+
num += shift;
76+
break;
77+
}
78+
break;
79+
}
80+
array[i] = (char)num;
81+
}
82+
return new string(array);
83+
}
84+
85+
static string DecryptInfo(string path)
86+
{
87+
var s = File.ReadAllText(path);
88+
s = Rot13(s.Substring(1));
89+
90+
s = Encoding.UTF8.GetString(Convert.FromBase64String(s));
91+
92+
return s;
93+
}
94+
95+
static string EncryptInfo(string path)
96+
{
97+
var json = File.ReadAllText(path);
98+
var utf8 = Encoding.UTF8.GetBytes(json);
99+
var base64 = Convert.ToBase64String(utf8);
100+
var shifted = Rot13(base64);
101+
return "\0" + shifted;
102+
}
103+
104+
string[] cli_args = Environment.GetCommandLineArgs();
105+
106+
if (cli_args.Length == 4 && cli_args[1] == "decrypt")
107+
{
108+
string json = DecryptInfo(cli_args[2]);
109+
File.WriteAllText(cli_args[3], json);
110+
111+
Console.WriteLine(json);
112+
} else if (cli_args.Length == 4 && cli_args[1] == "encrypt")
113+
{
114+
string bin = EncryptInfo(cli_args[2]);
115+
File.WriteAllText(cli_args[3], bin);
116+
} else
117+
{
118+
Console.WriteLine($"Command Line Usage: {cli_args[0]} (encrpyt|decrypt) in out");
119+
}

0 commit comments

Comments
 (0)