there is something wrong with encoding which i don't have time to search and figure it out
size goes from 3-4 mb to 8 mb after decryption
and whenever i decrypt it with other tool i find it fully functional (no idea what the fuck happens)
fix it then it's your's
please bother to lemme know what was wrong with the encoding
here is some codes and find the whole project in attachments
dat crypto class
Code:
[CODE]using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
namespace ItemType
{
public class MSRandom
{
public long Seed;
public MSRandom(int seed)
{
Seed = seed;
}
public int Next()
{
return (int)(((Seed = Seed * 214013L + 2531011L) >> 16) & 0x7fff);
}
}
public class DatCrypto
{
byte[] key;
public DatCrypto(int seed)
{
key = new byte[0x80];
MSRandom r = new MSRandom(seed);
for (int i = 0; i < key.Length; i++)
{
key[i] = (byte)(r.Next() % 0x100);
}
}
public byte[] Decrypt(byte[] b)
{
for (int i = 0; i < b.Length; i++)
{
int num = b[i] ^ key[i % 0x80];
int bits = i % 8;
b[i] = (byte)((num << (8 - bits)) + (num >> bits));
}
string exit = System.Text.Encoding.UTF7.GetString(b).Replace("@@", " ");
byte[] dd = new byte[(ulong)exit.Length];
try
{
for (int x = 0; x < dd.Length; x++)
{
if (x < dd.Length)
{
dd[x] = Convert.ToByte((exit[x] & 0xff));
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.ReadKey();
}
//Console.WriteLine(System.Text.Encoding.UTF7.GetString(b));
return dd;
}
public byte[] Encrypt(byte[] b)
{
string exit = System.Text.Encoding.UTF7.GetString(b).Replace(" ", "@@");
byte[] dd = new byte[(ulong)exit.Length];
try
{
for (int x = 0; x < dd.Length; x++)
{
if (x < dd.Length)
{
dd[x] = Convert.ToByte((exit[x] & 0xff));
}
}
}
catch (Exception e)
{
Console.WriteLine(e.ToString());
Console.ReadKey();
}
b = dd;
for (int i = 0; i < b.Length; i++)
{
int bits = i % 8;
int num = (byte)((b[i] >> (8 - bits)) + (b[i] << bits));
b[i] = (byte)(num ^ key[i % 0x80]);
}
return b;
}
}
}
form1
Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Globalization;
using System.IO;
namespace ItemType
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
static byte[] GetBytes(string str)
{
byte[] bytes = new byte[str.Length * sizeof(char)];
System.Buffer.BlockCopy(str.ToCharArray(), 0, bytes, 0, bytes.Length);
return bytes;
}
static string GetString(byte[] bytes)
{
char[] chars = new char[bytes.Length / sizeof(char)];
System.Buffer.BlockCopy(bytes, 0, chars, 0, chars.Length);
return new string(chars);
}
private byte[] Decrypt(byte[] lines)
{
string sseed = textBox7.Text;
int seed;
if (!int.TryParse(sseed, NumberStyles.HexNumber, null, out seed))
{
MessageBox.Show("Failed to parse the key value. Make sure it is an integer in hexadecimal format.");
return null;
}
DatCrypto dc = new DatCrypto(seed);
byte[] b = lines;
b = dc.Decrypt(b);
return b;
}
private byte[] Encrypt(byte[] lines)
{
string sseed = textBox7.Text;
int seed;
if (!int.TryParse(sseed, NumberStyles.HexNumber, null, out seed))
{
MessageBox.Show("Failed to parse the key value. Make sure it is an integer in hexadecimal format.");
return null;
}
DatCrypto dc = new DatCrypto(seed);
byte[] b = lines;
b = dc.Encrypt(b);
return b;
}
public byte[] decryptedlines;
public string[] ASSICdecryptedlines;
private void button1_Click(object sender, EventArgs e)
{
DialogResult result = openFileDialog1.ShowDialog();
if(result == DialogResult.OK)
{
string file = openFileDialog1.FileName;
byte[] b = null;
Log.Text += ("File openned succesfully");
try
{
b = File.ReadAllBytes(file);
}
catch
{
Log.Text += ("Failed to read the file");
return;
}
if (b != null)
{
Log.Text += ("succesfully Read everything");
b = Decrypt(b);
decryptedlines = b;
string s = Encoding.ASCII.GetString(b);
string[] ss = s.Split('\n');
ASSICdecryptedlines = ss;
foreach (string a in ss)
{
listBox1.Items.Add(a);
}
Log.Text += ("Itemtype had been decrypted");
Log.Text += ("Itemtype is displayed");
}
else
{
Log.Text += ("Failed to read the file [null string]");
}
}
else
{
MessageBox.Show("Please Select the Itemtype.dat");
Log.Text += ("Nothing had been selected at open file dialog");
}
}
private void listBox1_SelectedIndexChanged(object sender, EventArgs e)
{
try
{
string l = (string)listBox1.Text;
textBox1.Text = l.Split(' ')[0];
textBox2.Text = l.Split(' ')[1];
}
catch
{
Log.Text += ("End of list");
}
}
private void button4_Click(object sender, EventArgs e)
{
string[] items = new string[listBox1.Items.Count];
int i = 0;
foreach (string item in listBox1.Items)
{
items[i] = item;
if (item.Split(' ')[0] == textBox1.Text)
{
items[i] = item.Replace(item.Split(' ')[1], textBox2.Text);
}
i++;
}
listBox1.Items.Clear();
foreach (string a in items)
{
listBox1.Items.Add(a);
}
Log.Text += ("Item Edited");
}
private void button3_Click(object sender, EventArgs e)
{
string[] items = new string[listBox1.Items.Count]; items[0] = "test";
for (int i = 0; i < listBox1.Items.Count; i++)
{
listBox1.SelectedIndex = i;
items[i] = listBox1.Text;
}
int iii = 0;
foreach (string l in items)
{
string itemmmm = l.Split(' ')[0];
if (itemmmm != "")
{
string ee = "";
string eb = "";
switch (itemmmm[itemmmm.Length - 1])
{
case '9':
{
ee = l.Split(' ')[1];
eb = textBox5.Text + ee;
break;
}
case '8':
{
ee = l.Split(' ')[1];
eb = textBox6.Text + ee;
break;
}
case '7':
{
ee = l.Split(' ')[1];
eb = textBox3.Text + ee;
break;
}
case '6':
{
ee = l.Split(' ')[1];
eb = textBox4.Text + ee;
break;
}
default :
{
ee = l.Split(' ')[1];
eb = "[N]" + ee;
break;
}
}
items[iii] = l.Replace(ee, eb);
iii++;
}
}
listBox1.Items.Clear();
foreach (string a in items)
{
listBox1.Items.Add(a);
}
Log.Text += ("Everything is edited!");
}
private void Log_TextChanged(object sender, EventArgs e)
{
Log.ScrollToCaret();
}
private void button2_Click(object sender, EventArgs e)
{
string items = "" ;
foreach (string item in listBox1.Items)
{
items += (item + "\r\n");
}
byte[] b2 = GetBytes(items);
string patsh = Application.StartupPath + @"\EditedItemType.txt";
File.WriteAllBytes(patsh, b2);
byte[] b = File.ReadAllBytes(patsh);
DatCrypto dc = new DatCrypto(2537);
b = dc.Encrypt(b);
File.WriteAllBytes(Application.StartupPath + @"\EditedItemType.dat", b);
}
private void groupBox4_Enter(object sender, EventArgs e)
{
}
private void button7_Click(object sender, EventArgs e)
{
}
private void button6_Click(object sender, EventArgs e)
{
}
private void button5_Click(object sender, EventArgs e)
{
}
private void button9_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
}
private void button8_Click(object sender, EventArgs e)
{
string path = Application.StartupPath + @"/itemtype.txt";
string[] itemtype = File.ReadAllLines(path);
int iii = 0;
foreach (string l in itemtype)
{
string itemmmm = l.Split(' ')[0];
if (itemmmm != "")
{
string ee = "";
string eb = "";
switch (itemmmm[itemmmm.Length - 1])
{
case '9':
{
ee = l.Split(' ')[1];
eb = "[Super]" + ee;
break;
}
case '8':
{
ee = l.Split(' ')[1];
eb = "[Elite]" + ee;
break;
}
case '7':
{
ee = l.Split(' ')[1];
eb = "[Uni]" + ee;
break;
}
case '6':
{
ee = l.Split(' ')[1];
eb = "[Ref]" + ee;
break;
}
default:
{
//ee = l.Split(' ')[1];
//eb = "[N]" + ee;
break;
}
}
try
{
itemtype[iii] = l.Replace(ee, eb);
}
catch
{
}
iii++;
}
}
string nn = "";
foreach (string n in itemtype)
{
nn = nn + (n + "\r\n");
}
File.WriteAllText(Application.StartupPath + @"/itemtype2.txt", nn);
}
}
}
find the whole project in attachment
currently the editing of items is fully functional , use any other external tool to encrypt / decrypt
and yes i know that isn't the best way to code this shit







