Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
SHA256 for Authentication
Message
From
22/12/2021 04:30:31
 
 
To
21/12/2021 17:13:48
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
01683030
Message ID:
01683052
Views:
83
Denis, you're talking about DBF files, right?

Hash functions do not encrypt data: they create a digest for the data, so that two different byte sequences will get two different hash values. But you can't ("shouldn't") get back the original data given its hash value.

foxCryptoNG has methods that you can use for data encryption, but as soon as you encrypt the data, you won't be able to perform partial matches ($, AT(), LIKE, ...) from a SELECT.

I believe you can find discussions on a few workarounds, like creating temporary unencrypted cursors and perform the search on them, or break your name columns into references to an encrypted word table.

On the other hand, since you don't want to perform partial searches on identifiers (SSN, or VAT numbers, and so on), at least in principle, the columns that hold them are more easily encrypted and retrieved in your application.

>Hello Antonio,
>
>I'm trying to understand and I'm afraid I don't really get it :-)
>
>First let me tell you what I am looking for.
>
>Because of the GDPR (General Data Protection Regulation) adopted in many countries in Europe, I would like to find a tool that would let me encrypt data in some fields in some tables.
>
>So for example if I have a field for the FirstName of a customer that has 30 characters How can I use FoxCryptoNg?
>
>What determines the content and number if characters for m.Seed
>What determines the content and number if characters for m.ApiKey
>What determines the content and number if characters for m.ApiPin
>
>If I can use FoxCryptoNg to encrypt tha data in my fields how could I do a select based on certain needs?
>
>For example let's say I want to do the following
>
>Select FirstName from Cust where "John"$FirstName
>
>What would a select would look like with data encrypted with FoxCryptoNg?
>
>Regards.
>
>
>>Joy,
>>
>>Using the foxCryptoNG class at https://github.com/cwollenhaupt/foxCryptoNG:
>>
>>
>>LOCAL Crypto AS foxCryptoNG
>>LOCAL Seed AS String
>>LOCAL ApiKey AS String
>>LOCAL ApiPin AS String
>>LOCAL PreHash AS String
>>LOCAL ApiHash AS String
>>LOCAL Result64 AS String
>>LOCAL ExpectedResult64 AS String
>>
>>m.ExpectedResult64 = "X2ZDelgwdDB2UDMxMFZuMHJLelZFaWo0elNCYjdnMGo6czIvMzIxNDU2Nzg5MDEyMzQ1Njc4OTAxMjM0NTY3ODkw" + ;
>>	"LzAwMzVhMjJhNjU1MDllMTE4MTE5YjgwOWNhMDI4MDg3ZTQzMDdjNDUyZWZiNmFiNzk2NTViYTQ0ZDc5ZDFmOGM="
>>
>>m.Crypto = CREATEOBJECT("foxCryptoNG")
>>
>>m.Seed = "321456789012345678901234567890"
>>m.ApiKey = "_fCzX0t0vP310Vn0rKzVEij4zSBb7g0j"
>>m.ApiPin = "J105251T"
>>
>>m.PreHash = m.ApiKey + m.Seed + m.ApiPin
>>m.ApiHash = "s2/" + m.Seed + "/" + LOWER(m.Crypto.Hash_sha256(m.PreHash))
>>
>>m.Result64 = STRCONV(m.ApiKey + ":" + m.ApiHash, 13)
>>
>>IF m.Result64 == m.ExpectedResult64
>>
>>	MESSAGEBOX("Success!")
>>
>>ELSE
>>
>>	MESSAGEBOX("Fail...")
>>
>>ENDIF
>>
>>
>>>HI All,
>>>
>>>Just wondering if anyone ever coded the authentication header for USAePay API.
>>>I tried using vfpencryption.fll but the results did not come out correct.
>>>
>>>Here is the javascript code that works:
>>>var seed = "321456789012345678901234567890";
>>>var apikey = "_fCzX0t0vP310Vn0rKzVEij4zSBb7g0j";
>>>var apipin = "J105251T";
>>>var prehash = apikey + seed + apipin;
>>>var apihash = 's2/'+ seed + '/' + SHA256(prehash);
>>>var authKey = new Buffer(apikey + ":" + apihash).toString('base64');
>>>var authKey2 = (apikey + ":" + apihash).toString('base64');
>>>console.log("Authorization: Basic " + authKey);
>>>
>>>https://onecompiler.com/javascript/3xh8rx8pr
>>>
>>>My attempts to replicate this in VFP did not work.
>>>
>>>Thanks
>>>Joy Tan
----------------------------------
António Tavares Lopes
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform