@locohost: The link works for me ...
I got another problem - when I open my website with the browser, the php's echoes text is displayed, but when I try to get the result of the same addres ingame with httprequest_get_message_body, it returns an empty string "". The scripts were working correctly, but then the website was took down for a while to be approved - when it got back online, it simply stopped replying to the game. Why is this? I think the problem lies in the scripts, could it be somewhere else?
Try setting the User-Agent header to the User-Agent of an existing browser (e.g. "Mozilla/5.0"). Maybe the website doesn't respond to requests without a 'real' user agent (I've seen this a few times).
@IceMetalPunk:
Adding SHA-1 shouldn't be that hard, I will try it.
If I understand correctly, it works like this:
HMAC-MD5(message, key) = MD5(opad(key)+MD5(ipad(key)+message))
But I think MD5 is supposed to return a 16-byte binary string instead of a 32-byte hexadecimal string. You can do that with buffer_write_hex. I wrote a script for HMAC-MD5 and it gives the same results as PHP, so I think it works

.
// hmac_md5_string(message, key);
var b, i, c, h;
b = buffer_create();
c = min(string_length(argument1), 64);
// ipad
for(i = 0; i<c; i += 1) {
buffer_write_uint8(b, ord(string_char_at(argument1, i+1))^$36);
}
for(i = c; i<64; i += 1) {
buffer_write_uint8(b, $36);
}
// first hash
md5_begin();
md5_read_buffer(b);
md5_read_string(argument0);
md5_end();
h = md5_result();
buffer_clear(b);
// opad
for(i = 0; i<c; i += 1) {
buffer_write_uint8(b, ord(string_char_at(argument1, i+1))^$5c);
}
for(i = c; i<64; i += 1) {
buffer_write_uint8(b, $5c);
}
buffer_write_hex(b, h);
// second hash
md5_begin();
md5_read_buffer(b);
md5_end();
h = md5_result();
buffer_destroy(b);
return h;
Alternatively, if you want to calculate the HMAC of a buffer:
// hmac_md5_buffer(messagebuffer, key);
var b, i, c, h;
b = buffer_create();
c = min(string_length(argument1), 64);
// ipad
for(i = 0; i<c; i += 1) {
buffer_write_uint8(b, ord(string_char_at(argument1, i+1))^$36);
}
for(i = c; i<64; i += 1) {
buffer_write_uint8(b, $36);
}
// first hash
md5_begin();
md5_read_buffer(b);
md5_read_buffer(argument0);
md5_end();
h = md5_result();
buffer_clear(b);
// opad
for(i = 0; i<c; i += 1) {
buffer_write_uint8(b, ord(string_char_at(argument1, i+1))^$5c);
}
for(i = c; i<64; i += 1) {
buffer_write_uint8(b, $5c);
}
buffer_write_hex(b, h);
// second hash
md5_begin();
md5_read_buffer(b);
md5_end();
h = md5_result();
buffer_destroy(b);
return h;
Edited by Maarten Baert, 16 June 2011 - 03:32 PM.