Chinaunix
标题:
linux下实现getpass?
[打印本页]
作者:
aldslvda
时间:
2013-09-09 08:49
标题:
linux下实现getpass?
#include<unistd.h>
#include<stdio.h>
#include<conio.h>
#include<string.h>
int main()
{
char passwd[13];
char *key;
char slat[2];
key= getpass(“Input First Password:”);
slat[0]=key[0];
slat[1]=key[1];
strcpy(passwd,crypt(key slat));
key=getpass(“Input Second Password:”);
slat[0]=passwd[0];
slat[1]=passwd[1];
printf(“After crypt(),1st passwd :%s\n”,passwd);
printf(“After crypt(),2nd passwd:%s \n”,crypt(key slat));
}
复制代码
本来是想实现这样的程序
后来发现conio.h在linux下没有
有什么替代的方法吗?
作者:
flyingeagle1015
时间:
2013-09-09 09:23
拿你的代码改了下,可以运行。
#define _XOPEN_SOURCE
#include<unistd.h>
#include<stdio.h>
//#include<conio.h>
#include<string.h>
int main()
{
char passwd[13];
char *key;
char slat[2];
key= getpass("input First Password
);
slat[0]=key[0];
slat[1]=key[1];
strcpy(passwd,crypt(key,slat));
key=getpass("Input Second Password:"
;
slat[0]=passwd[0];
slat[1]=passwd[1];
printf("After crypt(),1st passwd :%s\n",passwd);
printf("After crypt(),2nd passwd:%s \n",crypt(key,slat));
欢迎光临 Chinaunix (http://bbs.chinaunix.net/)
Powered by Discuz! X3.2