Here. Have a working X-Sha-1 for C#.
public static byte[] HashData(byte[] data)
{
uint[] buffer = new uint[128];
Buffer.BlockCopy(data, 0, buffer, 0, data.Length);
int i;
uint a, b, c, d, e, g;
for (i = 0; i < 0x50; i++)
{
buffer[i + 16] = Rol(1, (int)(buffer[i] ^ buffer[i + 8] ^ buffer[i + 2] ^ buffer[i + 13]) % 32);
}
a = 0x67452301u;
b = 0xefcdab89u;
c = 0x98badcfeu;
d = 0x10325476u;
e = 0xc3d2e1f0u;
g = 0x00000000u;
for (i = 0; i < 20; i++)
{
g = buffer[i] + Rol(a, 5) + e + ((b & c) | (~b & d)) + 0x5a827999u;
e = d;
d = c;
c = Rol(b, 30);
b = a;
a = g;
}
for (; i < 40; i++)
{
g = (d ^ c ^ b) + e + Rol(g, 5) + buffer[i] + 0x6ed9eba1u;
e = d;
d = c;
c = Rol(b, 30);
b = a;
a = g;
}
for (; i < 60; i++)
{
g = buffer[i] + Rol(g, 5) + e + ((c & b) | (d & c) | (d & b)) - 0x70e44324u;
e = d;
d = c;
c = Rol(b, 30);
b = a;
a = g;
}
for (; i < 80; i++)
{
g = (d ^ c ^ b) + e + Rol(g, 5) + buffer[i] - 0x359d3e2au;
e = d;
d = c;
c = Rol(b, 30);
b = a;
a = g;
}
uint[] rInts = new uint[5];
rInts[0] = a + 0x67452301u;
rInts[1] = b + 0xefcdab89u;
rInts[2] = c + 0x98badcfeu;
rInts[3] = d + 0x10325476u;
rInts[4] = e + 0xc3d2e1f0u;
byte[] rBytes = new byte[20];
Buffer.BlockCopy(rInts, 0, rBytes, 0, 20);
return rBytes;
}
private static uint Rol(uint n, int shift)
{
return (uint)((n << shift) | (n >> (32 - shift)));
}
Edit: Changed some bad names... from "stuff" to "rInts" and "q" to "rBytes".[/i]
Is it just me or does that look almost exactly like Adron's HashData()?
Quote from: Mephisto on December 05, 2004, 11:01 PM
Is it just me or does that look almost exactly like Adron's HashData()?
I've never seen Adron's, but -- who cares? If Adron's is open-source then it should be translatable into other languages.
Its from bnetauth, couldn't find author so I assumed it was Yobguls.
But all the credit goes to Adron I guess.
Took me about 2 weeks to get this done... overflow checking was on :P
I will post the password and cdkey stuff as soon as I port it. Mabey I will put it in a nice little .Net dll.
GJ
Quote from: shout on December 06, 2004, 06:31 AM
overflow checking was on :P
LoL --
unchecked(
expression);
Quote from: MyndFyre on December 06, 2004, 04:04 PM
Quote from: shout on December 06, 2004, 06:31 AM
overflow checking was on :P
LoL --
unchecked(expression);
Or just turn overflow checking off for the whole project.
Quote from: shout on December 06, 2004, 08:53 PM
Quote from: MyndFyre on December 06, 2004, 04:04 PM
Quote from: shout on December 06, 2004, 06:31 AM
overflow checking was on :P
LoL --
unchecked(expression);
Or just turn overflow checking off for the whole project.
Sometimes that's not optimal. ;) You can also do entire unchecked blocks:
unchecked {
int m = (uint)n;
}
etc. :)
:p
As the thing above my pic indicates: I am no longer a newbie I have moved to junior member.
Quote from: shout on December 06, 2004, 09:32 PM
:p
As the thing above my pic indicates: I am no longer a newbie I have moved to junior member.
hehe. That has nothing to do with what I say. And I'm not trying to pick on you. ;)
I know I just give everyone shit all the time. Anything I say outside of code blocks should probably not be taken seroiusly.
And neither should my spelling.
Quote from: shout on December 06, 2004, 09:32 PM
:p
As the thing above my pic indicates: I am no longer a newbie I have moved to junior member.
There lots of Junior Members. However, there's only one Havoc Wreaker! :)
Quote from: Zakath on December 07, 2004, 01:06 AM
Quote from: shout on December 06, 2004, 09:32 PM
:p
As the thing above my pic indicates: I am no longer a newbie I have moved to junior member.
There lots of Junior Members. However, there's only one Havoc Wreaker! :)
I'm a fake admin! Go me!!
How do you change that? Do you have to have so many posts or something? (Excuse my noobness)
Quote from: shout on December 07, 2004, 07:36 AM
How do you change that? Do you have to have so many posts or something? (Excuse my noobness)
I don't believe that we peons have the ability to set our Custom Title. I believe you'll need to PM an Admin.