#include <stdio.h>
#include <unistd.h>
#include <stdint.h>
#include <string.h>
#include <openssl/md5.h>
int main () {
uint32_t hostid,i;
uint8_t hid[4];
uint8_t a1[] = { 0x4B,0x58,0x21,0x81,0x56,0x7B,0x0D,0xF3,0x21,0x43,0x9B,0x7E,0xAC,0x1D,0xE6,0x8A };
uint8_t a2[] = {
0x80,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00
};
char s[255];
MD5_CTX ctx;
gethostname(s,0x100);
hostid = gethostid();
for (i=0; i<strlen(s); i++) {
hostid += *(s + i);
}
hid[0] = (hostid >> 24) & 0xFF;
hid[1] = (hostid >> 16) & 0xFF;
hid[2] = (hostid >> 8) & 0xFF;
hid[3] = (hostid) & 0xFF;
MD5_Init(&ctx);
MD5_Update(&ctx,a1,16);
MD5_Update(&ctx,a2,40);
MD5_Update(&ctx,&hid,4);
MD5_Update(&ctx,a1,16);
MD5_Final(s,&ctx);
for (i=0; i<8; i++) {
printf("%X",(s[i]&0xFF));
}
printf("\n");
return 0;
}