The Cowboy 28 Posted October 28, 2013 public byte[] DecryptAccount(byte[] AccountData) { byte[] buffer = new byte[404]; byte[] firstbytes = new byte[16]; Array.Copy(AccountData, firstbytes, 16); Array.Resize(ref buffer, 16); Array.Copy(firstbytes, buffer, 16); System.Security.Cryptography.HMACSHA1 h = new System.Security.Cryptography.HMACSHA1(hmackey); byte[] rckey = h.ComputeHash(buffer); Array.Resize(ref rckey, 0x10); byte[] decrypteddata = new byte[388]; Array.Resize(ref buffer, 388); Array.Copy(AccountData, 0x10, buffer, 0, 388); RC4(ref buffer, rckey); Array.Copy(buffer, decrypteddata, 388); return decrypteddata; } public byte[] EncryptAccount(byte[] AccountData) { byte[] buffer = new byte[404]; Array.Copy(AccountData, 0, buffer, 0x10, AccountData.Length); System.Security.Cryptography.HMACSHA1 hs1 = new System.Security.Cryptography.HMACSHA1(hmackey); byte[] firstbytes = new byte[16]; Array.Copy(hs1.ComputeHash(AccountData), firstbytes, 16); Array.Copy(firstbytes, 0, buffer, 0, 16); byte[] rckey = hs1.ComputeHash(firstbytes); Array.Resize(ref rckey, 0x10); byte[] buffertwo = new byte[388]; Array.Copy(buffer, 0x10, buffertwo, 0, 388); RC4(ref buffertwo, rckey); Array.Copy(buffertwo, 0, buffer, 0x10, buffertwo.Length); return buffer; } public void RC4(ref Byte[] bytes, Byte[] key) { Byte[] s = new Byte[256]; Byte[] k = new Byte[256]; Byte temp; int i, j; for (i = 0; i < 256; i++) { s[i] = (Byte)i; k[i] = key[i % key.GetLength(0)]; } j = 0; for (i = 0; i < 256; i++) { j = (j + s[i] + k[i]) % 256; temp = s[i]; s[i] = s[j]; s[j] = temp; } i = j = 0; for (int x = 0; x < bytes.GetLength(0); x++) { i = (i + 1) % 256; j = (j + s[i]) % 256; temp = s[i]; s[i] = s[j]; s[j] = temp; int t = (s[i] + s[j]) % 256; bytes[x] ^= s[t]; } } I wanted to share it to help other people and i'd like to improve my code so i shared it. Quote Share this post Link to post Share on other sites
Swizzy 2083 Posted October 28, 2013 http://www.sendspace.com/file/4gdqi3 <--- an old project of mine that i made for a friend, a little over a year ago... might help 1 Quote Share this post Link to post Share on other sites
The Cowboy 28 Posted October 28, 2013 http://www.sendspace.com/file/4gdqi3 <--- an old project of mine that i made for a friend, a little over a year ago... might help OMG! Perfect code.Gonna use this for my next app, thanks a lot ! Quote Share this post Link to post Share on other sites
Swizzy 2083 Posted October 29, 2013 OMG! Perfect code.Gonna use this for my next app, thanks a lot ! My code for this project is REALLY bad... xD it's nowhere near clean or even optimized... 1 Quote Share this post Link to post Share on other sites
The Cowboy 28 Posted October 30, 2013 My code for this project is REALLY bad... xD it's nowhere near clean or even optimized... Well, since it is the best codding ive ever seen, i can think it is good. Quote Share this post Link to post Share on other sites
Swizzy 2083 Posted October 30, 2013 Well, since it is the best codding ive ever seen, i can think it is good. Thanks if you want i can clean it up for ya, make it easier to read and optimize it... 1 Quote Share this post Link to post Share on other sites
The Cowboy 28 Posted October 31, 2013 Thanks if you want i can clean it up for ya, make it easier to read and optimize it... if I understand it that way, it would be a lesson for me Quote Share this post Link to post Share on other sites
Swizzy 2083 Posted October 31, 2013 if I understand it that way, it would be a lesson for me http://www.sendspace.com/file/s90pp9 <--- there you go, much cleaner/better code i didn't change the RC4 implementation tho, your implementation of that is probably better (less code) but... i cba to verify that changes made to that actually work atm... 1 Quote Share this post Link to post Share on other sites