password calculation under linux

Not much to say about /etc/passwd and /etc/shadow.

The password stored in /etc/shadow is in the form of


username:$1$X1FNdStG$v8jqD184lDOuPeDoZqOc8.:17281:0:99999:7:::


Mainly look at the middle part

$encryption method&salt& encrypted data

$1$X1FNdStG$v8jqD184lDOuPeDoZqOc8.

so here

Encryption is 1

salt is X1FNdStG

The encrypted password is

v8jqD184lDOuPeDoZqOc8.


Specifically, man crypt can be used to investigate the case. Encryption method 1 is md5 encryption but not standard md5?)


call code to implement


#define _XOPEN_SOURCE
#include <stdio.h>
#include <unistd.h>
int main(int argc, char *argv[])
{
char key[20] = "root";
char salt[20] = "$1$X1FNdStG";
printf("%s\n", crypt(key, salt));
return 0;
}

use when compiling

gcc -o main main.c -lcrypt


Execute is OK.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326133338&siteId=291194637