Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Ideas for storing numeric data encrypted?
Message
From
14/06/2018 16:20:38
John Ryan
Captain-Cooker Appreciation Society
Taumata Whakatangi ..., New Zealand
 
 
To
14/06/2018 11:52:49
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows Server 2012 R2
Network:
Windows Server 2012 R2
Database:
Visual FoxPro
Application:
Desktop
Virtual environment:
VMWare
Miscellaneous
Thread ID:
01660727
Message ID:
01660733
Views:
94
>>Anyhow, just thought I would ask in case someone who does more "mathy" stuff knows if VFP has some capability I am not aware of.

Helicopter view = encryption needs to reliably obfuscate and de-obfuscate values. For strings, faulty decryption usually is easily detected. For numerics, it could be a big problem if the error is not immediately obvious. Especially where rounding is involved in VFP. E.g. "Albert" decrypting back to "Al$5rCF" is a fairly obvious glitch, but $100.32 decrypting back to $100.30 isn't obvious unless somebody is watching closely.

So for numerics I'd say the immediately obvious ofuscation is adding or subtracting that doesn't risk rounding. Floating point multiplication or any other function that risks rounding, could mess you up.

Ideally the added value differs per record, so it can't be guessed by knowing one value. As an example you could use a derivative of SYS(2017) or SYS(2007) to get a CRC for each record and add that. Example: calculate remainder of a division on CRC of decrypted username. The following code shows unpredictably different numerics: not only is the CRC hugely different for slightly different names, but the % remainder obfuscates futther (and helps avoid numeric overflow situations): also means a hacker would need to decrypt the username, know to use CRC, and know your denominator:
lnPayment=105.54

lcDecryptedname="GOSTICK, Albert"
? "Albert =",m.lnpayment

lnObfuscatedpayment=m.lnPayment+VAL(SYS(2007,m.lcDecryptedName,0,1))%12345
? "Obfuscated=",m.lnObfuscatedpayment

lnUnobfuscatedpayment=lnObfuscatedpayment-VAL(SYS(2007,m.lcDecryptedName,0,1))%12345
? "Unobfuscated=",lnUnobfuscatedpayment

?

lcDecryptedname="GOSTICK, Alberta"
? "Alberta=",m.lnPayment

lnObfuscatedpayment=m.lnPayment+VAL(SYS(2007,m.lcDecryptedName,0,1))%12345
? "Obfuscated=",m.lnObfuscatedpayment

lnUnobfuscatedpayment=lnObfuscatedpayment-VAL(SYS(2007,m.lcDecryptedName,0,1))%12345
? "Unobfuscated=",lnUnobfuscatedpayment
Note that without inside information, this is enough to thwart casual examination and most hackers, but somebody who knows how to hook VFP can deduce all your encryption efforts in minutes. If that's a concern, the latest Refox or Defox or (my favourite) VFP Compiler have only ever been convincingly hacked by 3 people, 2 of whom are authors of 2 of these products. Level of paranoia depends who you need to protect yourself from!
"... They ne'er cared for us
yet: suffer us to famish, and their store-houses
crammed with grain; make edicts for usury, to
support usurers; repeal daily any wholesome act
established against the rich, and provide more
piercing statutes daily, to chain up and restrain
the poor. If the wars eat us not up, they will; and
there's all the love they bear us.
"
-- Shakespeare: Coriolanus, Act 1, scene 1
Previous
Reply
Map
View

Click here to load this message in the networking platform