Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Encrypting a table field
Message
De
10/01/2000 23:23:07
 
 
À
10/01/2000 23:02:12
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00315680
Message ID:
00315968
Vues:
37
>You need to exercise a bit of care in selecting values for the key. It's not terribly secure, but it's easy, free, and self-extracting, IOW:
>
>CryptXOR(CryptXOR('abcdefg','MyKey'),'MyKey')
>
>will give back the unencrypted value.

That's cute. I'll study it more later.

I wanted something that would generate printable characters so I could store encoded credit card numbers in a memo field. This is part of the code:
***********************************************************************
* 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 lcCrypto
I 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.

Peter
Peter Robinson ** Rodes Design ** Virginia
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform