*********************************************************************** * FUNCTION EncodeRS() LIBRARY FPRS\PROGS\ *********************************************************************** * Purpose.....: Returns a character string which is an encrypted version * of the character string tcString. * Parameters..: tcString * tnSeed * Returns.....: character -- encoded string * Notes.......: The input string is stripped of leading and trailing blanks * and then padded with blanks to a length which is divisible by 4 * The encoded string consists of the characters A through P * with a blank inserted after every 8 characters. * Examples....: lcEncodedString = EncodeRS(lcString) * Calls.......: BintoNib() * Project.....: Rodes Software FoxPro Utilities * Version.....: 1999 * Platform....: Visual FoxPro 5.0 * Author......: Peter Robinson * Copyright...: (c) Rodes Software, 1999 * Created.....: 1999.02.10 * History.....: ********************************************************************** lparameter tcString, tnSeed local lcString && Input string with leading & trailing blanks removed local lnPad && number of spaces to add to the end of tcString local lnW && pointer to first byte of each word (4 bytes) local lnWord && bit value of each word local lcCrypto && encoded string if type("tcString") <> "C" or empty(tcString) return "" endif if type("tnSeed") <> "N" or tnSeed = 0 return "" endif lcString = alltrim(tcString) lnPad = len(lcString) % 4 if lnPad <> 0 lcString = lcString + space(4-lnPad) endif rand(tnSeed) lcCrypto = "" for lnW = 1 to len(lcString) - 1 step 4 lnWord = ctobin(substr(lcString,lnW,4)) lnWord = bitxor(lnWord,rand()*2147483647) lcCrypto = lcCrypto + BintoNib(lnWord) + " " endfor return lcCryptoI think mine is a good bit more secure because it uses a 32 bit seed and the mask changes with every four bytes. May be faster too since I XOR 4 bytes at a time.