home *** CD-ROM | disk | FTP | other *** search
/ Power CD-ROM!! 7 / POWERCD7.ISO / prgmming / clipper / decrypt.prg < prev    next >
Text File  |  1993-10-14  |  3KB  |  107 lines

  1. /*
  2.  * File......: DECRYPT.PRG
  3.  * Author....: Martin Colloby
  4.  * BBS.......: The Dark Knight Returns
  5.  * Net/Node..: 050/069
  6.  * User Name.: Martin Colloby
  7.  * Date......: 18/4/93
  8.  * Revision..: 1.0
  9.  *
  10.  * This is an original work by Martin Colloby and is placed in the public
  11.  * domain.
  12.  *
  13.  * Modification history:
  14.  * ---------------------
  15.  *
  16.  * $Log$
  17.  *
  18.  */
  19.  
  20.  
  21. /*  $DOC$
  22.  *  $FUNCNAME$
  23.  *      GT_DECODE
  24.  *  $CATEGORY$
  25.  *      Security
  26.  *  $ONELINER$
  27.  *      Decode an encoded string
  28.  *  $SYNTAX$
  29.  *      GT_Decode( cString )
  30.  *  $ARGUMENTS$
  31.  *      cString - String to be decoded
  32.  *  $RETURNS$
  33.  *      The tring in a decoded format
  34.  *  $DESCRIPTION$
  35.  *      Uses a decryption algorithm to decode a string that has been encoded
  36.  *      using GT_Encode()
  37.  *  $EXAMPLES$
  38.  *
  39.  *  $SEEALSO$
  40.  *
  41.  *  $INCLUDE$
  42.  *      GT_LIB.CH
  43.  *  $END$
  44.  */
  45.  
  46. *
  47. #include "GT_lib.ch"
  48.  
  49. FUNCTION GT_Decode( cString )
  50.  
  51. /*****************************************************************************
  52.  Purpose - Decode an encoded string
  53.  Returns - Decoded string
  54.  Author  - Gevin Keeley
  55.  Created - 3/3/92
  56.  Edited  - 25/4/92 by Martin Colloby - Tidied up
  57. ******************************************************************************
  58.  Parameters - cString - String to decode
  59.  Privates   - None
  60.  Locals     - None
  61.  Externals  - None
  62. *****************************************************************************/
  63.  
  64. RETURN( ALLTRIM( GT_Deencrypt( ALLTRIM( cString ) ) ) )
  65. *
  66. STATIC FUNCTION GT_Deencrypt( cString )
  67.  
  68. /*****************************************************************************
  69.  Purpose - De-encrypt a string
  70.  Returns - De-encrypted string
  71.  Author  - Gevin Keeley
  72.  Created - 3/3/92
  73.  Edited  - 25/4/92 by Martin Colloby - Tidied up
  74. ******************************************************************************
  75.  Parameters - cString - String to deencrypt
  76.  Privates   - None
  77.  Locals     - cChar   - Current character
  78.               cRetStr - String to return
  79.               nCount  - Count of characters processed
  80.               nInt    - Integer part of character code
  81.               nLength - Length of cString
  82.               nRem    - Remainder of character code
  83.  Externals  - None
  84. *****************************************************************************/
  85.  
  86. LOCAL cChar := ""
  87. LOCAL cRetStr := ""
  88. LOCAL nCount := 1
  89. LOCAL nInt := 0
  90. LOCAL nLength := LEN( cString )
  91. LOCAL nRem := 0
  92.  
  93. DO WHILE nCount <= nLength
  94.     nInt := ASC( SUBSTR( cString , nCount , 1 ) )
  95.  
  96.     nRem := ASC( SUBSTR( cString , nCount + 1 , 1 ) )
  97.  
  98.     cChar := CHR( nInt * 17 + nRem )
  99.  
  100.     IIF( cChar == CHR( 0 ), , cRetStr += cChar )
  101.  
  102.     nCount += 2
  103. ENDDO
  104.  
  105. RETURN cRetStr
  106. *
  107.