Update.
[platform/upstream/glibc.git] / manual / examples / testpass.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <unistd.h>
4 #include <crypt.h>
5
6 int 
7 main(void)
8 {
9   /* Hashed form of "GNU libc manual".  */
10   const char *const pass = "$1$/iSaq7rB$EoUw5jJPPvAPECNaaWzMK/";
11
12   char *result;
13   int ok;
14   
15 /*@group*/
16   /* Read in the user's password and encrypt it,
17      passing the expected password in as the salt.  */
18   result = crypt(getpass("Password:"), pass);
19 /*@end group*/
20
21   /* Test the result.  */
22   ok = strcmp (result, pass) == 0;
23
24   puts(ok ? "Access granted." : "Access denied.");
25   return ok ? 0 : 1;
26 }