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

Source: Internet
Author: User
Tags crypt

Source code such as the following:

#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 password cryptographic function, which is based on the Data Encryption Standard (DES) algorithm. Crypt is only applicable to the use of password and is not suitable for data encryption. 

crypt()将參数key所指的字符串加以加密。key字符串长度仅取前8个字符,超过此长度的字符没有意义。參数salt为两个字符组成的字符串,由a-z、A-Z、0-9。“.”和“/”所组成,用来决定使用4096 (a-z、A-Z、0-9。“.”和“/”共64个字符。64的平方为4096)种不同内建表格的哪一个。函数运行成功后会返回指向编码过的字符串指针,參数key 所指的字符串不会有所更动。编码过的字符串长度为13 个字符。前两个字符为參数salt代表的字符串。返回值: 返回一个指向以NULL结尾的password字符串。注意编译时要在末尾加入 -lcrypt 选项。

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

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.