Skip to content
This repository was archived by the owner on Dec 1, 2024. It is now read-only.

Commit f6e7174

Browse files
committed
Beautified code
1 parent 7568ab4 commit f6e7174

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

Program.cs

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,12 @@
33
using System.Security.Cryptography;
44
using System.Text;
55

6-
main();
7-
86
static byte[] GenerateByte()
97
{
108
int length = new Random().Next(2, 7);
119
byte[] numArray = new byte[length];
1210
for (int index = 0; index < length; ++index)
13-
numArray[index] = 0;
11+
numArray[index] = 0;
1412
return numArray;
1513
}
1614

@@ -19,7 +17,7 @@ static string GenerateRandomString(int length)
1917
Random random = new Random();
2018
StringBuilder stringBuilder = new StringBuilder(length);
2119
for (int index = 0; index < length; ++index)
22-
stringBuilder.Append("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"[random.Next("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz".Length)]);
20+
stringBuilder.Append("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz"[random.Next("ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz".Length)]);
2321
return stringBuilder.ToString();
2422
}
2523

@@ -28,35 +26,35 @@ static void ShuffleMD5(string file)
2826
int num = new FileInfo(file).Length > 1048576L ? 1048576 : 4096;
2927
byte[] numArray = GenerateByte();
3028
using (FileStream fileStream = new FileStream(file, (FileMode)6))
31-
(fileStream).Write(numArray, 0, numArray.Length);
29+
fileStream.Write(numArray, 0, numArray.Length);
3230
using (MD5 md5 = MD5.Create())
3331
{
3432
using (FileStream fileStream = new FileStream(file, (FileMode)3, (FileAccess)1, (FileShare)1, num))
35-
Console.WriteLine("New MD5 hash: " + BitConverter.ToString((md5).ComputeHash(fileStream)).Replace("-", ""));
33+
Console.WriteLine("New MD5 hash: " + BitConverter.ToString(md5.ComputeHash(fileStream)).Replace("-", ""));
3634
}
3735
}
3836

3937
static string ShuffleName(string currentDirectory, string oldFilePath)
4038
{
4139
Path.GetFileNameWithoutExtension(oldFilePath);
4240
string randomString = GenerateRandomString(8);
43-
string str = Path.Combine(currentDirectory, randomString + ".exe");
41+
string newFilePath = Path.Combine(currentDirectory, randomString + ".exe");
4442
try
4543
{
46-
File.Move(oldFilePath, str);
44+
File.Move(oldFilePath, newFilePath);
4745
DefaultInterpolatedStringHandler interpolatedStringHandler = new DefaultInterpolatedStringHandler(17, 2);
4846
interpolatedStringHandler.AppendLiteral("Renamed '");
4947
interpolatedStringHandler.AppendFormatted(oldFilePath);
5048
interpolatedStringHandler.AppendLiteral("' to '");
51-
interpolatedStringHandler.AppendFormatted(str);
49+
interpolatedStringHandler.AppendFormatted(newFilePath);
5250
interpolatedStringHandler.AppendLiteral("'.");
5351
Console.WriteLine(interpolatedStringHandler.ToStringAndClear());
5452
}
5553
catch (IOException ex)
5654
{
5755
Console.WriteLine("An error occurred: " + ex.Message);
5856
}
59-
return str;
57+
return newFilePath;
6058
}
6159

6260
static void main()
@@ -73,11 +71,11 @@ static void main()
7371
Console.WriteLine("Shuffling Hash, one moment..");
7472
ShuffleMD5(list[0]);
7573
Console.WriteLine("Shuffling exe name, one moment..");
76-
string str = ShuffleName(baseDirectory, list[0]);
74+
string newFileName = ShuffleName(baseDirectory, list[0]);
7775
Console.WriteLine("Shuffling complete, launching exe.");
7876
Process.Start(new ProcessStartInfo()
7977
{
80-
FileName = str,
78+
FileName = newFileName,
8179
UseShellExecute = true
8280
});
8381
}
@@ -97,3 +95,5 @@ static void main()
9795
Console.ReadLine();
9896
}
9997
}
98+
99+
main();

0 commit comments

Comments
 (0)