Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Encrypting a field in SQL Server
Message
From
18/01/2019 09:20:56
Lutz Scheffler
Lutz Scheffler Software Ingenieurbüro
Dresden, Germany
 
General information
Forum:
Visual FoxPro
Category:
Databases,Tables, Views, Indexing and SQL syntax
Miscellaneous
Thread ID:
01665536
Message ID:
01665539
Views:
55
>Hi,
>
>This description is somewhat simplified but close enough for this question.
>
>In my app, password module, there is a table on SQL Server, UserGroup. This table has a field ACCESS_CODE Char(250). The entry in this field looks something like this:
>
>"YNNNYYYYNNN"
>
>that is the entry in this field consists of "Y" and "N". The application "knows" that a position (for example) 100 in this field specifies if the user has access to feature X. That is, if position 100 has entry "N", a user will not be allowed access to feature X.
>
>Right now, the entire table and the field are not encrypted. It has not been a problem since my customers are very low-tech and never connect to SQL Server to check these things.
>
>But it bothers me. So, I would like to encrypt this field. But in such way, that from the VFP application I can manipulate the entries (e.g. Change "Y" to "N" or the other way around).
>
>I am considering using the cipher() function created by Sergey Berezniker. I use this function in other places in my app, for encryption. My only "problem" with cipher() is that the app has to be absolutely sure when it encrypts and when it decrypts a string. That is, if the function is applied to a encrypted string attempting to encrypt it, a problem entry occurs.
>
>Does SQL Server offer a better way to encrypt such a field with ability to change the entry from the VFP 9 app?
>
>TIA

I don't know for SQL Server, but if you fear to encrypt encrypted this might help:
?DoEncrypt('YYNNY')
?DoEncrypt('BlaBla')

FUNCTION DoEncrypt
 LPARAMETERS;
  tcString

 IF LEN(CHRTRAN(m.tcString,'YN',''))=0 THEN
  RETURN 'encrypted'
 ELSE &&LEN(CHRTRAN(m.tcString,'YN',''))=0
  RETURN 'fail'
 ENDIF &&LEN(CHRTRAN(m.tcString,'YN',''))=0

ENDFUNC &&DoEncrypt
Encrypted stuff will use different chars then just NY. This is no proof in math sense, but a good aproximation.
If you have some time, it's only 2^250 encryptions to test it! :)
Words are given to man to enable him to conceal his true feelings.
Charles Maurice de Talleyrand-Périgord

Weeks of programming can save you hours of planning.

Off

There is no place like [::1]
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform