home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Usenet 1994 October
/
usenetsourcesnewsgroupsinfomagicoctober1994disk2.iso
/
misc
/
volume6
/
shadow-2.pt2
/
obscure.c
< prev
next >
Wrap
C/C++ Source or Header
|
1989-02-03
|
2KB
|
104 lines
#include <ctype.h>
#include "config.h"
/*
* Obscure - see if password is obscure enough.
*
* The programmer is encouraged to add as much complexity to this
* routine as desired. Included are some of my favorite ways to
* check passwords.
*/
extern char pass[]; /* the new password */
extern char orig[]; /* the original password */
char mono[32]; /* a monocase version of pass */
int obscure ()
{
int i;
if (orig[0] == '\0')
return (1);
if (strlen (pass) < 6) { /* too short */
printf ("Too short. ");
return (0);
}
#ifdef OBSCURE
for (i = 0;pass[i];i++)
mono[i] = tolower (pass[i]);
if (strcmp (pass, orig) == 0) /* the same */
return (0);
if (palindrome ()) /* a palindrome */
return (0);
if (caseshift ()) /* upper/lower case changes only */
return (0);
if (similiar ()) /* jumbled version of original */
return (0);
#endif
return (1);
}
#ifdef OBSCURE
/*
* can't be a palindrome - like `R A D A R' or `M A D A M'
*/
int palindrome ()
{
int i, j;
i = strlen (pass);
for (j = 0;j < i;j++)
if (pass[i - j - 1] != pass[j])
return (0);
printf ("No palindromes. ");
return (1);
}
/*
* may not be a shifted version of original
*/
int caseshift ()
{
int i;
for (i = 0;pass[i] && orig[i];i++) {
if (tolower (pass[i]) == tolower (orig[i]))
continue;
else
return (0);
}
printf ("May not be case-shifted. ");
return (1);
}
/*
* more than half of the characters are different ones.
*/
int similiar ()
{
int i, j;
char *strchr ();
for (i = j = 0;pass[i] && orig[i];i++)
if (strchr (mono, tolower (orig[i])))
j++;
if (i - j > 2)
return (0);
printf ("Too similiar. ");
return (1);
}
#endif