crypt函数salt如何取值才能得到和shadow中的密码串一致? - C/C++ - ...
来源:百度文库 编辑:神马文学网 时间:2024/04/28 03:28:59
GNU EXTENSION
The glibc2 version of this function has the following additional features. If salt is a character string
starting with the three characters "$1$" followed by at most eight characters, and optionally terminated
by "$", then instead of using the DES machine, the glibc crypt function uses an MD5-based algorithm, and
outputs up to 34 bytes, namely "$1$$", where "" stands for the up to 8 characters
following "$1$" in the salt, and "" is a further 22 characters. The characters in "" and
"" are drawn from the set [a-zA-Z0-9./]. The entire key is significant here (instead of only
the first 8 bytes).
Programs using this function must be linked with -lcrypt.
[root@server tmp]# useradd prettywolf
[root@server tmp]# passwd prettywolf
Changing password for user prettywolf.
New UNIX password: 12345
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@server tmp]# tail -1 /etc/shadow
prettywolf:$1$qY9g/6K4$KTVzAcT.TMgkASuMWh6kJ1:13826:0:99999:7:::
[root@server tmp]# cat c.c
#include
#include
int main(void) {
char *salt = "$1$qY9g/6K4$";
printf("%s\n", crypt("12345", salt));
return(0);
}
[root@server tmp]# gcc -o c c.c -lcrypt
[root@server tmp]# ./c
$1$qY9g/6K4$KTVzAcT.TMgkASuMWh6kJ1
The glibc2 version of this function has the following additional features. If salt is a character string
starting with the three characters "$1$" followed by at most eight characters, and optionally terminated
by "$", then instead of using the DES machine, the glibc crypt function uses an MD5-based algorithm, and
outputs up to 34 bytes, namely "$1$
following "$1$" in the salt, and "
"
the first 8 bytes).
Programs using this function must be linked with -lcrypt.
[root@server tmp]# useradd prettywolf
[root@server tmp]# passwd prettywolf
Changing password for user prettywolf.
New UNIX password: 12345
BAD PASSWORD: it is too short
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@server tmp]# tail -1 /etc/shadow
prettywolf:$1$qY9g/6K4$KTVzAcT.TMgkASuMWh6kJ1:13826:0:99999:7:::
[root@server tmp]# cat c.c
#include
#include
int main(void) {
char *salt = "$1$qY9g/6K4$";
printf("%s\n", crypt("12345", salt));
return(0);
}
[root@server tmp]# gcc -o c c.c -lcrypt
[root@server tmp]# ./c
$1$qY9g/6K4$KTVzAcT.TMgkASuMWh6kJ1
crypt函数salt如何取值才能得到和shadow中的密码串一致? - C/C++ - ...
c函数: strtok 和 strtok_r
c函数的取整 (floor, ceil)--WHED
C ++中的虚函数(virtual function)
C 中的虚函数(virtual function)
C/C++中的函数参数传递机制
C 中的虚函数(virtual function)
C/C++中的函数参数传递机制
C中如何调用C++函数
C语言再学习 之 函数指针和指针函数
c语言把串中的一部分与另一串中的一部分比较, 不管大小写函数
c语言中串拷贝函数
c语言中串比较函数
c extern函数用法
C#中如何得到主机名与IP地址
C利用辅助函数获取Mysql数据库和表信息
C利用辅助函数获取Mysql数据库和表信息
如何混合使用C和C (上)
如何混合使用C和C (下)
如何混合使用C和C (上) - robin
如何理解c和c ++的复杂类型声明
c/c++中的日期和时间
c/c++中函数指针的含义 [c/c++]---01
C语言字符串函数大全