Page 1 of 1

Encryption of Credit Card Numbers

Posted: Wed Feb 17, 2010 5:23 pm
by rdonnay
I received this by private email. I am posting it here so everyone can see this.

"The Plan" was to,

1. Get the Credit Card info
2. ENCRYPT the data string when SAVING the Client Record
3. Save the Encrypted String in the Client DBF Record

4. Retrieve it by pressing the "Decrypt" button while editing

I tested this using your sample in \exp19\samples\encrypt

It works ONCE both in encrypting and decrypting. I skip to the next record and try the same function and I get the error "Internal data structure corrupted", in both functions, at 2nd to last line "dllExecuteCall(scCall, instr/cKey. @cOutput)". Attached most of the code, the DBF, and xpperror.log.

Re: Encryption of Credit Card Numbers

Posted: Wed Feb 17, 2010 5:28 pm
by rdonnay
I figured out the problem. Make the below changes to \exp19\samples\encrypt\test.prg.

Code: Select all

Function Decrypt(inStr)

LOCAL cKey, cOutput := Space(512)

STATIC snDll, scCall

IF Empty(snDll)
  snDll := DllLoad('DESDLL.DLL')
  scCall := DllPrepareCall(snDll,DLL_STDCALL,'DESDecrypt')
  // cKey := 'DonnaySoftware'  <<< remove this
ENDIF
cKey := 'DonnaySoftware'  // <<< put it here

DllExecuteCall(scCall,inStr,cKey,@cOutput)

RETURN Strtran(RTrim(cOutput),Chr(0),'')

* --------------

Function Encrypt(inStr)

LOCAL cKey, cOutput := Space(512)

STATIC snDll, scCall

IF Empty(snDll)
  snDll:=DllLoad('DESDLL.DLL')
  scCall:=DllPrepareCall(snDll,DLL_STDCALL,'DESEncrypt')
  // cKey := 'DonnaySoftware'  <<< remove this
ENDIF
cKey := 'DonnaySoftware'  // <<< put it here

DllExecuteCall(scCall,inStr,cKey,@cOutput)

RETURN Left(RTrim(cOutput),Len(cOutput)-1)