设为首页 加入收藏

TOP

PostgreSQL用户密码如何通过md5加密存储并加了salt(二)
2019-03-19 14:09:30 】 浏览:196
Tags:PostgreSQL 用户 密码 如何 通过 md5 加密 存储 加了 salt
N + 1);
(gdb)
128            if (!pg_md5_encrypt(password, role, strlen(role),
(gdb) s
pg_md5_encrypt (passwd=0x99c3b4c "123456", salt=0x99c3b3c "yzs", salt_len=3, buf=0x9a0d984 "") at md5.c:326
326    size_t      passwd_len = strlen(passwd);
(gdb) n
329    char      *crypt_buf = malloc(passwd_len + salt_len + 1);
(gdb)
332    if (!crypt_buf)
(gdb)
339    memcpy(crypt_buf, passwd, passwd_len);
(gdb)
340    memcpy(crypt_buf + passwd_len, salt, salt_len);
(gdb) p crypt_buf
$1 = 0x9979e68 "123456A"
(gdb) n
342    strcpy(buf, "md5");
(gdb) p crypt_buf
$2 = 0x9979e68 "123456yzs?\tQ"
(gdb) n
343    ret = pg_md5_hash(crypt_buf, passwd_len + salt_len, buf + 3);
(gdb) p crypt_buf
$3 = 0x9979e68 "123456yzs?\tQ"
(gdb) n
345    free(crypt_buf);
(gdb) p crypt_buf
$4 = 0x9979e68 "123456yzs?\tQ"
(gdb) n
347    return ret;
(gdb)
348 }
(gdb) p ret
$5 = 1 '\001'
(gdb) n
encrypt_password (target_type=PASSWORD_TYPE_MD5, role=0x99c3b3c "yzs", password=0x99c3b4c "123456") at crypt.c:131
131            return encrypted_password;
(gdb)
146 }
(gdb)
CreateRole (pstate=0x9a0d804, stmt=0x99c3bbc) at user.c:415
415                CStringGetTextDatum(shadow_pass);
(gdb) p shadow_pass
$6 = 0x9a0d984 "md5aed8080c314507e15542d5e9519723a8"


3、从pg_authid表中观察该用户经过md5加过密的密码值,可以看出和堆栈信息中看到的一样


postgres=# select *from pg_authid where rolname='yzs';
 rolname | rolsuper | rolinherit | rolcreaterole | rolcreatedb | rolcanlogin | rolreplication | rolbypa***ls | rolconnlimit |            rolpassword            | rolvaliduntil
---------+----------+------------+---------------+-------------+-------------+----------------+--------------+--------------+-------------------------------------+---------------
 yzs    | f        | t          | f            | f          | t          | f              | f            |          -1 | md5aed8080c314507e15542d5e9519723a8 |
(1 row)


首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇使用Navicat快速生成MySQL数据字典 下一篇PostgreSQL逻辑备份恢复--pg_dump..

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目