|
是时间基数计算出来,附件中是我几年前帮公司写的代码
- BOOL CGrubMd5::GetMD5PWD(char *pwd, char *md5pwd)
- {
- char crypted[36];
- char key[32];
- unsigned int seed;
- //int i;
- const char *const seedchars =
- "./0123456789ABCDEFGHIJKLMNOPQRST"
- "UVWXYZabcdefghijklmnopqrstuvwxyz";
- /* First create a salt. */
- int i;
- memset (key, 0, sizeof (key));
- lstrcpy(key,pwd);
- /* The magical prefix. */
- memset (crypted, 0, sizeof (crypted));
- memmove (crypted, "$1$", 3);
- seed=(time(NULL))%16+1;
- printf("send: %i\n",seed);
- for (i = 0; i < 8 && seed; i++)
- {
- // * FIXME: This should be more random.
- crypted[3 + i] = seedchars[seed & 0x3f];
- seed >>= 6;
- }
- crypted[3 + i] = '$';
- // printf ("salt = %s\n", crypted);
- /* Get a password. */
- /* A salt must be terminated with `$', if it is less than 8 chars. */
- // get_cmdline ("Password: ", key, sizeof (key) - 1, '*', 0);
- /* Crypt the key. */
- make_md5_password (key, crypted);
- // printf ("Encrypted: %s\n", crypted);
- lstrcpy(md5pwd,crypted);
- ////////////////////////
- return 0;
- }
复制代码
[ 本帖最后由 snowground 于 2010-3-27 02:07 编辑 ] |
|