C 리눅스 환경에서
보통 암호 입력시 별표로 출력이 대신해서 나오는 것을 해보고 싶습니다.
scanf로는 안될 듯 싶네요.
그래서 알아보던 중에 다른 라이브러리를 쓰면 된다고 하는데
종류가 굉장히 많아서 잘 모르겠습니다. 현재 수준은
C 문법만 아는 정도 입니다. 아무튼...
어떤 라이브러리의 어떤 함수를 써야 하는지 알려주시면
감사하겠습니다. 지금 그 부분을 모르고 있습니다...
int main() { printf("you input is (%s)\n", inputpass()); return 0; }
#include <termios.h> #include <stdio.h>
#define MAX_PASS_LEN 16 static char passwd[MAX_PASS_LEN]; static char *inputpass(void);
static char *inputpass(void) { char temp; int i = 0; struct termios old, new;
tcgetattr(fileno(stdin), &old); new = old; // 반향을 제거한다. new.c_lflag =~ ECHO; tcsetattr(fileno(stdin), TCSAFLUSH, &new);
printf("password "); while((temp=getchar()) != '\n') { if (i == MAX_PASS_LEN) break; passwd[i] = temp; i++; } // 원래 터미널 상태로 되돌린다. tcsetattr(fileno(stdin), TCSANOW, &old); return passwd; }
*^^*
getpass()라는 함수가 있습니다.
위의 답변해주신 소스코드를 알려주셔서 감사드립니다... 프로그램을 만들어보고 싶어서 의욕이 넘칩니다...^^ 프로그램을 만드는데 도움을 주셔서 감사합니다.
텍스트 포맷에 대한 자세한 정보
<code>
<blockcode>
<apache>
<applescript>
<autoconf>
<awk>
<bash>
<c>
<cpp>
<css>
<diff>
<drupal5>
<drupal6>
<gdb>
<html>
<html5>
<java>
<javascript>
<ldif>
<lua>
<make>
<mysql>
<perl>
<perl6>
<php>
<pgsql>
<proftpd>
<python>
<reg>
<spec>
<ruby>
<foo>
[foo]
출처 : 조인시 위키
int main()
{
printf("you input is (%s)\n", inputpass());
return 0;
}
#include <termios.h>
#include <stdio.h>
#define MAX_PASS_LEN 16
static char passwd[MAX_PASS_LEN];
static char *inputpass(void);
static char *inputpass(void)
{
char temp;
int i = 0;
struct termios old, new;
tcgetattr(fileno(stdin), &old);
new = old;
// 반향을 제거한다.
new.c_lflag =~ ECHO;
tcsetattr(fileno(stdin), TCSAFLUSH, &new);
printf("password ");
while((temp=getchar()) != '\n')
{
if (i == MAX_PASS_LEN) break;
passwd[i] = temp;
i++;
}
// 원래 터미널 상태로 되돌린다.
tcsetattr(fileno(stdin), TCSANOW, &old);
return passwd;
}
*^^*
getpass()라는 함수가 있습니다.
getpass()라는 함수가 있습니다.
감사합니다.
위의 답변해주신 소스코드를
알려주셔서 감사드립니다...
프로그램을 만들어보고 싶어서
의욕이 넘칩니다...^^
프로그램을 만드는데 도움을 주셔서 감사합니다.
댓글 달기