void my_make_scrambled_password(char *to, const char *password, size_t pass_len) { uint8 hash_stage2[SHA1_HASH_SIZE]; /* Two stage SHA1 hash of the password. */ compute_two_stage_sha1_hash(password, pass_len, (uint8 *) to, hash_stage2); /* convert hash_stage2 to hex string */ *to++= PVERSION41_CHAR; octet2hex(to, (const char*) hash_stage2, SHA1_HASH_SIZE); }
void make_scrambled_password(char *to, const char *password) { SHA1_CONTEXT sha1_context; uint8 hash_stage2[SHA1_HASH_SIZE]; mysql_sha1_reset(&sha1_context); /* stage 1: hash password */ mysql_sha1_input(&sha1_context, (uint8 *) password, (uint) strlen(password)); mysql_sha1_result(&sha1_context, (uint8 *) to); /* stage 2: hash stage1 output */ mysql_sha1_reset(&sha1_context); mysql_sha1_input(&sha1_context, (uint8 *) to, SHA1_HASH_SIZE); /* separate buffer is used to pass 'to' in octet2hex */ mysql_sha1_result(&sha1_context, hash_stage2); /* convert hash_stage2 to hex string */ *to++= PVERSION41_CHAR; octet2hex(to, (char*) hash_stage2, SHA1_HASH_SIZE); }
void make_password_from_salt(char *to, const uint8 *hash_stage2) { *to++= PVERSION41_CHAR; octet2hex(to, (char*) hash_stage2, SHA1_HASH_SIZE); }