Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Text Encryption - what was that command?!
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Autre
Divers
Thread ID:
00101352
Message ID:
00101373
Vues:
17
Thanks - I'll give these suggestions a test. I appreciate you both for giving me your code. -- Sarah

>>Ages ago I worked on a fox 2.6 system which encrypted passwords and stored them in a text field. Next time the user logged in the password was encrypted and and checked against the stored version.
>>
>>I've looked through help and can't find the command to do the encryption. Can anyone help me?
>>
>>What I plan to do is issue the people who buy my program a code based on their surname (last name) and both will be entered into the system. If the surname, when encrypted, doesn't match the code then reports and exports are disabled. The users surname is printed on all reports so if they pass the software around they'll have to have another person's name on all their stuff which will hopefully aggravate them into buying a legit copy.
>>
>>Maybe someone else has a better idea? or method?
>
>I'm using the following routines for password encryption.
>
>
>   * *********************************************
>   *  FUNCTION    EncryptPass
>   *  Author   Steve Ruhl
>   *  Written     March 14, 1996
>   *  Description
>   *     Encrypt passwords
>   *  Passed:
>   *     lcCryptStr  CHAR     Password to encrypt / decrypt
>   *     lcWordLen   NUM      Length of password string
>   *  Returns:
>   *                 CHAR      Encrypted string
>   *  NOTES Function converts the password to all UPPER case characters before
>   *   encrypting it.
>   *   If the value to be encrypted is all blanks, or is a null string,
>   *   it is returned as all blanks as well, rather than being actually
>   *   encrypted.
>   *   When encrypting a string, the string to be encrypted is padded
>   *   to the length specified in the <tnWordLength> parameter.   The
>   *   string returned is actually one character longer than the
>   *   <tnWordLength>, because the "offset character" for decrypting the
>   *   first actual character of the string is added to the front of
>   *   the string.
>   *  Usage:
>   *     lcVar = EncryptPass( tcPasswordString, tnWordLength )
>   * *********************************************
>FUNCTION EncryptPass( tcPasswordString,tnWordLength )
>
>   LOCAL lcWrkStr		&& Temp storage for encrypted string
>   LOCAL lcWrkChar		&& Character buing encrypted
>   LOCAL lcWrkPass		&& Encrypted password
>   LOCAL lcOffset		&& Offset character
>   LOCAL llDone			&& Done flag
>   LOCAL lnI			&& Loop counter
>
>   IF !EMPTY( tcPasswordString )
>      lcWrkStr = PADR( UPPER( tcPasswordString ), tnWordLength )
>      STORE '' TO lcWrkPass, lcWrkChar
>
>      *---Generate a random ascii code for the offset character
>      lcOffset = MOD( RAND( -1 ) * 10000, 255 ) + 1
>
>      lcWrkPass = CHR( lcOffset )   && Store offset character as first character in the translated string
>
>      FOR lnI=1 TO tnWordLength     && Parse characters from input string
>         lcWrkChar = SUBSTR( lcWrkStr, lnI, 1 )
>
>         *---The character is encrypted as follows:
>         *  1: Take its ASCII value
>         *  2: Add value of the offset
>         *  3: MOD this new number by 255 to make sure it is a legal ASCII value
>         *  4: Convert it back into an ASCII character
>
>         lcWrkChar = CHR( MOD( ASC( lcWrkChar ) + lcOffset, 255 ) + 1 )
>         lcWrkPass = lcWrkPass + lcWrkChar
>
>         *---The ASCII value of this encrypted character is then used as the
>         *---offset for the next character. In this way, the offset value
>         *---changes for each character, making it harder to decrypt.
>         lcOffset = ASC( lcWrkChar )
>      ENDFOR
>
>   ELSE       && If string to be encrypted is blank
>      lcWrkPass = SPACE( tnWordLength + 1 )  && return blanks as the encrypted value.
>   ENDIF
>   RETURN (lcWrkPass)
>ENDFUNC
>
>* *********************************************
>*  FUNCTION    DecryptPass
>*  Author   Steve Ruhl
>*  Written     March 14, 1996
>*  Description
>*     Decrypt passwords
>*  Passed:
>*     lcCryptStr  CHAR     Password to decrypt
>*     lcWordLen   NUM      Length of password string
>*  Returns:
>*                 CHAR      Decrypted string
>*  NOTES Function always returns all characters in UPPER case.
>*  Usage:
>*     lcVar = DecryptPass( tcPasswordString, tnWordLength )
>* *********************************************
>FUNCTION DecryptPass( tcPasswordString,tnWordLength )
>
>   LOCAL lcWrkStr
>   LOCAL lcWrkChar
>   LOCAL lcWrkPass
>   LOCAL lcOffset
>   LOCAL llDone
>   LOCAL lnI
>
>   IF !EMPTY( tcPasswordString )
>
>      STORE '' TO lcWrkPass, lcWrkChar
>      lcWrkStr  = SUBSTR( tcPasswordString, 2 )
>      tnWordLength = LEN( tcPasswordString )
>      llDone    = .F.
>
>      *---Determine offset value of first character
>      lcOffset = ASC( tcPasswordString )
>
>      *---Note first character is skipped because it is only the "offset
>      *   character" for the first character of the actual string
>      FOR lnI = 2 TO tnWordLength
>         lcWrkChar = SUBSTR( tcPasswordString, lnI, 1 )
>
>         IF ASC( lcWrkChar ) <= lcOffset
>            lcWrkPass = lcWrkPass + CHR( 255 + ASC( lcWrkChar ) - lcOffset - 1 )
>         ELSE
>            lcWrkPass = lcWrkPass + CHR( ASC( lcWrkChar ) - lcOffset - 1 )
>         ENDIF
>
>         lcOffset = ASC( lcWrkChar )
>
>      ENDFOR
>   ELSE
>      lcWrkPass = SPACE( tnWordLength )
>   ENDIF
>
>   RETURN (lcWrkPass)
>ENDFUNC
>
>
Sarah King
pcpropertymanager.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform