Linux password Encryption Program (can be used to replace the user password in the shadow file)

Source: Internet
Author: User
Tags crypt

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)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.