Create a hash with any data
Hi, i would want to know how to create a hash of a data.
I've already know crypt() and how to create a md5 hash with it, but problems come when any byte is equal to zero, because de crypt function declaration is:
char * crypt(const char * key , const char *salt);
e.g:
struct data{
int x;
int y;
int z;
}
struct data var1;
var1.x = 5;
var1.y = 0;
var1.z = 5;
hash = crypt((char *) &var1, "$1$");
/*the hash is: (for example) $1$ZH$YGGYInw6oH0P29Ze6hlo.1
again, with different data, (pay attention to var2.z)
*/
struct data var2;
var2.x = 5;
var2.y = 0;
var2.z = 115;
hash = crypt((char *) &var2, "$1$");
/*the hash will be the same, since var2.z parameter which is different from first, is not passed, because var2.y is null-byte, and the string ends */
Could anybody show me another function to create a hash which i can pass null-byte data??
Thanks In Advance
|