File: cracklib_example.c

package info (click to toggle)
cracklib2 2.7-19
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 384 kB
  • ctags: 114
  • sloc: ansic: 1,931; sh: 67; makefile: 65; perl: 46
file content (40 lines) | stat: -rw-r--r-- 1,064 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
/*
  copyright:
    Copyright (C) 1998, 1999 Jean Pierre LeJacq <jplejacq@quoininc.com>
    Cleaned up 2003 by Martin Pitt <martin@piware.de>

    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 <crack.h>
#include <stdio.h>

int main()
{
    char password[80U] = "";
    char const* msg;

    puts( "Example program using cracklib" );
    printf( "Enter potential password: " );
    scanf( "%79s", password );

    msg = FascistCheck( password, CRACKLIB_DICTPATH );

    if( msg ) {
	puts( "Please use a different password." );
	printf( "The one you have chosen is unsuitable because:\n %s\n", msg );
    } else
	puts( "Good password." );

    return 0;
}