I'll just port it all from java then, because I found a working unsigned right shift function, and I find java more understandable that C.
This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.
Show posts Menu
extern t_uint32 bn_int_get(bn_int const src)
{
t_uint32 temp;
if (!src)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL src");
return 0;
}
temp = ((t_uint32)src[0]) ;
temp |= ((t_uint32)src[1])<< 8;
temp |= ((t_uint32)src[2])<<16;
temp |= ((t_uint32)src[3])<<24;
return temp;
}
extern void bnhash_to_hash(bn_int const * bnhash, t_hash * hash)
{
unsigned int i;
if (!bnhash)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL bnhash");
return;
}
if (!hash)
{
eventlog(eventlog_level_error,__FUNCTION__,"got NULL hash");
return;
}
for (i=0; i<5; i++)
(*hash)[i] = bn_int_get(bnhash[i]);
}
private void calculateHash(uint clientToken, uint serverToken)
{
if (!valid)
throw new InvalidOperationException(Resources.invalidCdKeyHashed);
MemoryStream ms = new MemoryStream(26);
BinaryWriter bw = new BinaryWriter(ms);
bw.Write(clientToken);
bw.Write(serverToken);
switch (key.Length)
{
case 13:
case 16:
bw.Write(product);
bw.Write(val1);
bw.Write((int)0);
bw.Write(val2);
bw.Write((short)0);
hash = XSha1.CalculateHash(ms.GetBuffer());
break;
case 26:
bw.Write(product);
bw.Write(val1);
bw.Write(val2);
byte[] buffer = ms.GetBuffer();
SHA1 sha = new SHA1Managed();
hash = sha.ComputeHash(buffer);
break;
default:
break;
}
ms.Close();
}
Public Function DecodeMapData(ByVal Encoded As String) As String
Dim enc() As Byte
Dim dec() As Byte
Dim I As Long
Dim J As Long
Dim D As Byte
Dim lngLen As Long
enc = System.Text.UnicodeEncoding.Unicode.GetBytes(Encoded)
For I = 0 To UBound(enc)
If (I Mod 8) Then
ReDim Preserve dec(lngLen)
dec(lngLen) = (enc(I) And (D >> (1 + J) Or Not 1))
J = J + 1
lngLen = lngLen + 1
Else
J = 0
D = enc(I)
End If
Next I
Return System.Text.UnicodeEncoding.Unicode.GetString(dec)
End Function
Page created in 0.278 seconds with 16 queries.