PDA

View Full Version : Generating and checking HASH's to confirm record not tampered with



Movian
06-30-2014, 08:43 AM
Hey,
I have a requirement to hash records in a table to allow us to check if its been tampered with. When we display the records with an SQL query, I am trying to figure out how to check the records when accessed against that hash to ensure they are accurate and then have an extra column in the list box to say that it matches the hash.


So we have a list box with a basic query as record source "Select * FROM tblEvents WHERE Event Date Between '01/01/2001' AND '06/30/2014'" for example.

What I want to end up with is an extra column named "Integrity Checked" with Yes for columns where the stored hash matches a current hash.

Would rather not make a button that needs to be pressed to check the integrity and generate a report but I can do it that way if there is no way to do what I am trying to do.

(I do already have a function for generating SHA256 hashes that I will be using and I will be salting these hashes with a private key to generate the hashes stored in the table.)

jonh
07-02-2014, 02:45 AM
I guess you would call your existing function from the query.

Integrity Checked: IIf(gethash({values})=[storedhash],"Yes")

Movian
07-07-2014, 11:59 AM
you can call vba functions as part of an SQL Script??!??

I will be doing some Google searching on how to format this correctly... any chance you could layout an example as a basic SELECT FROM WHERE to save me some time ?

Select *, if(crypto.sha256(field1 & Field2 etc.. etc..) =[storedhash],"Yes") as [integrity checked] FROM tblEvents

something like that ?

I have the function as part of a crypto class so I just call it as Crypto.SHA256

thanks!

jonh
07-08-2014, 12:29 AM
Something like that.
You can call any public function from a standard module.
I've never used a class with a query. Not sure how / if that would work.