home *** CD-ROM | disk | FTP | other *** search
- /*********
- *
- * _TR_PNUM.C
- *
- * by Tom Rettig
- * modified by Leonard Zerman
- *
- * Placed in the public domain by Tom Rettig Associates, 10/22/1990.
- *
- * long _tr_pnum( *char )
- *
- * called by _tr_crypt for encrypt() and decrypt(), and by password()
- *
- *********/
-
- #include "trlib.h"
-
- long _tr_pnum( s )
- char *s;
- {
- long ret = 1L;
- int i;
-
- if ( s[0] && s[1] && s[2] ) /* 3 char minimum password len */
- {
- /* sum the ascii values of each char */
- for ( i = 0; s[i]; i++ )
- ret += (long) (s[i] + i);
-
- /* bit shift ret 1 position to the left until ret exceeds PW_MIN_NUM */
- for (; ret < (PW_MIN_NUM); ret <<= 1 )
- ;
- return( ret );
- }
- else
- return( ERRORNEGL ); /* -1 for error */
- }
-
-