Valhalla Legends Forums Archive | Battle.net Bot Development | [C#]Hashing

AuthorMessageTime
shout
Here. Have a working X-Sha-1 for C#.

[code]
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 ^ 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)));
}
[/code]

[i]Edit: Changed some bad names... from "stuff" to "rInts" and "q" to "rBytes".
December 6, 2004, 4:25 AM
Mephisto
Is it just me or does that look almost exactly like Adron's HashData()?
December 6, 2004, 5:01 AM
Myndfyr
[quote author=Mephisto link=topic=9793.msg91199#msg91199 date=1102309282]
Is it just me or does that look almost exactly like Adron's HashData()?
[/quote]

I've never seen Adron's, but -- who cares?  If Adron's is open-source then it should be translatable into other languages.
December 6, 2004, 8:47 AM
shout
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.
December 6, 2004, 12:31 PM
Mephisto
GJ
December 6, 2004, 3:21 PM
Myndfyr
[quote author=shout link=topic=9793.msg91215#msg91215 date=1102336300]
overflow checking was on  :P
[/quote]

LoL --

unchecked(expression);
December 6, 2004, 10:04 PM
shout
[quote author=MyndFyre link=topic=9793.msg91249#msg91249 date=1102370691]
[quote author=shout link=topic=9793.msg91215#msg91215 date=1102336300]
overflow checking was on  :P
[/quote]

LoL --

unchecked(expression);
[/quote]

Or just turn overflow checking off for the whole project.
December 7, 2004, 2:53 AM
Myndfyr
[quote author=shout link=topic=9793.msg91322#msg91322 date=1102388015]
[quote author=MyndFyre link=topic=9793.msg91249#msg91249 date=1102370691]
[quote author=shout link=topic=9793.msg91215#msg91215 date=1102336300]
overflow checking was on  :P
[/quote]

LoL --

unchecked(expression);
[/quote]

Or just turn overflow checking off for the whole project.
[/quote]

Sometimes that's not optimal.  ;)  You can also do entire unchecked blocks:

[code]
unchecked {
  int m = (uint)n;
}
[/code]

etc. :)
December 7, 2004, 3:29 AM
shout
:p

As the thing above my pic indicates: I am no longer a newbie I have moved to junior member.
December 7, 2004, 3:32 AM
Myndfyr
[quote author=shout link=topic=9793.msg91330#msg91330 date=1102390330]
:p

As the thing above my pic indicates: I am no longer a newbie I have moved to junior member.
[/quote]

hehe.  That has nothing to do with what I say.  And I'm not trying to pick on you.  ;)
December 7, 2004, 3:33 AM
shout
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.
December 7, 2004, 3:35 AM
Zakath
[quote author=shout link=topic=9793.msg91330#msg91330 date=1102390330]
:p

As the thing above my pic indicates: I am no longer a newbie I have moved to junior member.
[/quote]

There lots of Junior Members. However, there's only one Havoc Wreaker! :)
December 7, 2004, 7:06 AM
Soul Taker
[quote author=Zakath link=topic=9793.msg91350#msg91350 date=1102403196]
[quote author=shout link=topic=9793.msg91330#msg91330 date=1102390330]
:p

As the thing above my pic indicates: I am no longer a newbie I have moved to junior member.
[/quote]

There lots of Junior Members. However, there's only one Havoc Wreaker! :)
[/quote]
I'm a fake admin!  Go me!!
December 7, 2004, 7:12 AM
shout
How do you change that? Do you have to have so many posts or something? (Excuse my noobness)
December 7, 2004, 1:36 PM
Myndfyr
[quote author=shout link=topic=9793.msg91368#msg91368 date=1102426569]
How do you change that? Do you have to have so many posts or something? (Excuse my noobness)
[/quote]

I don't believe that we peons have the ability to set our Custom Title.  I believe you'll need to PM an Admin.
December 7, 2004, 2:03 PM

Search