/* source: /var/cvs/projects/debian/cracklib/debian/dpkg.src/cracklib2-dev.cracklib_example.c.in,v revision: @(#) cracklib2-dev.cracklib_example.c.in,v 1.2 1999/03/29 15:30:21 jplejacq Exp copyright: Copyright (C) 1998, 1999 Jean Pierre LeJacq Distributed under the GNU GENERAL PUBLIC LICENSE. description: cracklib_example - an example of using cracklib Nothing fancy here. Simply need to call FascistCheck() with the potential password and the path+prefix to the dictionary database. I'm using the path+prefix, CRACKLIB_DICTPATH, used by the utilities in the cracklib-runtime package. FascistCheck() will return non-NULL if the password is not selected. */ #include #include #include signed main(void) { char password[80U] = ""; (void)printf("Example program using cracklib\n"); (void)printf("Enter potential password: "); (void)scanf("%79s", password); { char const * const msg = FascistCheck(password, CRACKLIB_DICTPATH); if (0 != msg) { (void)printf("Please use a different password.\n"); (void)printf("The one you have chosen is unsuitable because:\n"); (void)printf(" %s\n", msg); } else { (void)printf("Good password.\n"); } } return EXIT_SUCCESS; }