The source code is as follows:
#include <stdio.h>#include <unistd.h>intMainintARGC, Char*ARGV[]){if(ARGC! =3){printf("%s <salt> <crypt>\n", argv[0]);return-1; } Char*passwd=Crypt(argv[1],argv[2]);printf("passwd: %s\ n", passwd);return 0;}
Summarize:
Char*crypt (Const Char*Key,Const Char*salt); Crypt is a cryptographic function that is based on the Data Encryption Standard (DES) algorithm. Crypt only applies to the use of passwords and is not suitable for data encryption. Crypt () the parameterKeyThe string being referred to is encrypted,KeyString length is only taken before8Characters, characters beyond this length have no meaning. The parameter salt is a two-character string consisting of A-Z, A-Z,0-9,“.” and "/" are used to determine the use of4096(A-Z, A-Z,0-9,“.” and "/" total -Characters, -The square is4096) Which of the different built-in tables. When the function executes successfully, it returns a pointer to the encoded string, the parameterKeyThe string you refer to does not change. The encoded string length is -Characters, the first two characters are the string represented by the parameter salt. Return value: Returns a pointer to a null-terminated password string. Note the-lcrypt option at compile time to be added at the end.
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Linux password Encryption Program (can be used to replace the user password in the shadow file)