Skip to content

Instantly share code, notes, and snippets.

@jedisct1
Created April 2, 2011 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jedisct1/899591 to your computer and use it in GitHub Desktop.
Save jedisct1/899591 to your computer and use it in GitHub Desktop.
#if MYSQL_VERSION_ID < 40100 || defined(USE_OLD_MYSQL_SCRAMBLING)
unsigned long hash_res[2];
char scrambled_password[MYSQL_CRYPT_LEN];
# if MYSQL_VERSION_ID < 40100
hash_password(hash_res, password);
# else
hash_password(hash_res, password, strlen(password));
# endif
snprintf(scrambled_password, sizeof scrambled_password, "%08lx%08lx",
hash_res[0], hash_res[1]);
#else
char scrambled_password[42]; /* 2 * 20 (sha1 hash size) + 2 */
# if MYSQL_VERSION_ID >= 40100 && MYSQL_VERSION_ID < 40101
make_scrambled_password(scrambled_password, password, 1, NULL);
# else
# ifdef HAVE_MY_MAKE_SCRAMBLED_PASSWORD
my_make_scrambled_password(scrambled_password, password,
strlen(password));
# else
make_scrambled_password(scrambled_password, password);
# endif
# endif
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment