File: cracklib_example.c

package info (click to toggle)
cracklib2 2.9.2-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 3,148 kB
  • ctags: 411
  • sloc: sh: 11,875; ansic: 2,632; xml: 365; python: 288; makefile: 207; sed: 16
file content (41 lines) | stat: -rw-r--r-- 1,124 bytes parent folder | download | duplicates (10)
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
41
/*
  copyright:
    Copyright (C) 1998, 1999 Jean Pierre LeJacq <jplejacq@quoininc.com>
    Cleaned up 2003 by Martin Pitt <martin@piware.de>
    Adapted to new upstream 2008 by Jan Dittberner <jan@dittberner.info>

    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, NULL );

    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;
}