Created
November 18, 2018 19:29
-
-
Save goaaats/115a6f1be6bd6b3d59548b40a18e2cb5 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.IO; | |
using System.Net; | |
using System.Security.Cryptography; | |
using System.Text; | |
namespace FFLogsRehash | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
var lines = File.ReadAllLines(args[0]); | |
int lineCount = 0; | |
for (int i = 0; i < lines.Length; i++) | |
{ | |
lines[i] = lines[i].Substring(0, lines[i].LastIndexOf("|")); | |
var lineType = lines[i].Substring(0, lines[i].IndexOf("|")); | |
if (lineType == "01" || lineType == "253") | |
lineCount = 1; | |
else | |
lineCount++; | |
lines[i] = lines[i] + "|" + Meme(lines[i] + "|" + lineCount); | |
} | |
File.WriteAllLines(Path.GetFileNameWithoutExtension(args[0]) + "_rehashed.log", lines); | |
} | |
private static string Meme(string text) | |
{ | |
MD5 md = MD5.Create(); | |
byte[] bytes = md.ComputeHash(Encoding.UTF8.GetBytes(text)); | |
return Mangle(bytes); | |
} | |
private static uint[] MakeConstant() | |
{ | |
uint[] array = new uint[256]; | |
for (int i = 0; i < 256; i++) | |
{ | |
string text = i.ToString("X2").ToLower(); | |
array[i] = (uint)(text[0] + ((uint)text[1] << 16)); | |
} | |
return array; | |
} | |
private static string Mangle(byte[] bytes) | |
{ | |
uint[] lookup = MakeConstant(); | |
char[] array = new char[bytes.Length * 2]; | |
for (int i = 0; i < bytes.Length; i++) | |
{ | |
uint num = lookup[(int)bytes[i]]; | |
array[2 * i] = (char)num; | |
array[2 * i + 1] = (char)(num >> 16); | |
} | |
return new string(array); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment