03-27-2012, 06:07 PM
OK, that is awesome. Thanks for information. I was able to reproduce it with Per's hash and salt. Here is some demo code:
Hash: UQgnz/vPWap9UeD8Dhaw3h/fgFA= -> 510827cffbcf59aa7d51e0fc0e16b0de1fdf8050
Code:
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include "openssl/sha.h"
#define SWAP(x) ((((x) & 0xff000000) >> 24) | (((x) & 0x00ff0000) >> 8) | (((x) & 0x0000ff00) << 8) | (((x) & 0x000000ff) << 24))
int main (int argc, char **argv)
{
// hash to find: 510827CFFBCF59AA7D51E0FC0E16B0DE1FDF8050
// salt: 7c6276c27ff95a5cea4280de080da45c
unsigned char salt[16] =
{
0x7c, 0x62, 0x76, 0xc2,
0x7f, 0xf9, 0x5a, 0x5c,
0xea, 0x42, 0x80, 0xde,
0x08, 0x0d, 0xa4, 0x5c,
};
unsigned char pass[24] =
{
't', 0, 'e', 0, 's', 0, 't', 0,
'P', 0, 'a', 0, 's', 0, 's', 0,
'w', 0, 'o', 0, 'r', 0, 'd', 0,
};
unsigned int sha1hash[5];
SHA_CTX ctx;
SHA1_Init (&ctx);
SHA1_Update (&ctx, salt, sizeof (salt));
SHA1_Update (&ctx, pass, sizeof (pass));
SHA1_Final ((unsigned char *) sha1hash, &ctx);
sha1hash[0] = SWAP (sha1hash[0]);
sha1hash[1] = SWAP (sha1hash[1]);
sha1hash[2] = SWAP (sha1hash[2]);
sha1hash[3] = SWAP (sha1hash[3]);
sha1hash[4] = SWAP (sha1hash[4]);
printf ("%08x%08x%08x%08x%08x\n", sha1hash[0], sha1hash[1], sha1hash[2], sha1hash[3], sha1hash[4]);
return 0;
}
Quote:root@sf:~# gcc-4.4 -o tec tec.c -lssl
root@sf:~# ./tec
510827cffbcf59aa7d51e0fc0e16b0de1fdf8050
Hash: UQgnz/vPWap9UeD8Dhaw3h/fgFA= -> 510827cffbcf59aa7d51e0fc0e16b0de1fdf8050