Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Using Crypto Class
Message
General information
Forum:
Visual FoxPro
Category:
Classes - VCX
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Vista
Network:
Windows 2000 Pro
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01452254
Message ID:
01452475
Views:
65
Ok, if rippped out of sample form the code below & amended to not pick up the string from the sample table but into my own as below:-
oCrypto = Newobject("_cryptapi", HOME()+[FFC\_crypt.vcx])
#DEFINE	NOCSP_LOC	"The required Crypto Service Provider is not installed or not functioning properly on this system. Some or all of these samples may not work."
IF !OCrypto.GetIsInstalled()
	MESSAGEBOX(NOCSP_LOC)
	RETURN .F.
ENDIF
LOCAL lcEncryptedStream,lcPassword,lcKey
lcEncryptedStream = ''
lcDecryptedStream = ''

lcPassWord = "Christine"
lcKey = "Secret Password"
IF ocrypto.EncryptSessionBlockString(lcPassWord, lcKey, @lcEncryptedStream)
ELSE
	IF ocrypto._cryptapi.GetDoubleEncryptError()
		MESSAGEBOX("Sorry, you cannot double-encrypt this text.")
	ELSE
		MESSAGEBOX("Error: "+MESSAGE())
	ENDIF
	RETURN
ENDIF
?lcEncryptedStream
REPLACE name WITH ALLTRIM(lcEncryptedStream)
lcfield=ALLTRIM(name)
mresult=ocrypto.DecryptSessionStreamString(lcField, lcKey, @lcDecryptedStream)
?lcDecryptedStream
I don't get back my original text (in this case Christine) but different encypted text.

I know I can crack this, it's 99% there LOL



>loCrypto = NEWOBJECT(........)
>But you should add VCX in your project.
>
>
>>Many thanks everyone for your help so far
>>
>>Had a quick look in the samples folder of VFP, & theres a sample form that seems to work fine. Great!
>>
>>It's using the solutions.vcx class
>>
>>Don't want to use a form though, how do I programmaticaly get the class as an object from code instead of being on a form?
>>
>>>>I've written a couple of routines for my customer to encrypt several fields in a table, so that the data can't be copied & taken off site
>>>>
>>>>I've used the "_cryptapi" class, (customers preference)
>>>>
>>>>Using the class if I encrypt a string, decrypting it gives me my original string, but when I put the encrypted string into the original field that the string is from in the table, when I read it back later and decrypt it I sometimes get the right results, sometimes I don't.
>>>>
>>>>TAI
>>>
>>>Make the field to be CHAR BINARY or MEMO BINARY (NOCPTRANS)
Rob
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform