Source language: Translate to:

Can NB get a unique identity from a file?

General questions about NeoBook

Moderator: Neosoft Support

Can NB get a unique identity from a file?

Postby Enigman » Tue Aug 19, 2014 9:25 pm

Is it possible for a NB app to pull a unique identifier from a database file? I'm talking about a Windows system identifier and not data within the file. I would like to examine an Access file for the identifier, and then key data inside the database to that identifier. In order to be useful, the identifier would have to be something permanent that was established when the file was created.

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Re: Can NB get a unique identity from a file?

Postby dec » Wed Aug 20, 2014 12:10 am

Hello,

I am not sure if you can apply the idea, but, maybe it's possible to get some "hash" from the file and use this hash as an identifier for the file.

If you like take a look at my npHash plugin. ;)
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Can NB get a unique identity from a file?

Postby Enigman » Wed Aug 20, 2014 8:13 am

dec,

Thanks for the reply.

Although I am not fully up to speed on how hash values work, a quick read at Wikipedia would indicate that hash values are the opposite of what I need. The hash value of a file is dependant upon the data in the file and the hash result changes when the contents of the file change.

I need something more like a serial number that is in the file properties header from the time the file is created and never changes again regardless of how the file content changes. From the viewpoint of a database file, this means I am identifying the "container of data" rather than verifying the "data in the container". To use a food analogy, I need to positively identify the bowl regardless of the food in the bowl.

I can do this the brute force way by adding a serial number to the filename, but that makes the identification visible and allows accidental invalidation if the user, not knowing what all that gooblygook in the name is for, manually changes the name of the file. Since we are talking about an Access database, I could also place the ID in a field in a table, but that is also open to intentional changes by someone trying to access the contents without the program.

My preference would be to either use something already in the file header, or put something in the properties of the file header to use as an ID, so that it is not easily apparent that there is an ID at all.

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Re: Can NB get a unique identity from a file?

Postby dec » Wed Aug 20, 2014 8:55 am

Hello,

I understand. However, what kind of files you want to get/set the ID for? I think this approach is not valid for every type of files. Some files (like TXT files) do not have any header in which store any information. Maybe you need to change your point of view, or, in other words, take another possible approach to do what you wanted. Do not understand me: I just think that sometimes we want to do something... that maybe can be doing using another more affordable approach. Anyway wait for another possible answer from other mate. ;)
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Can NB get a unique identity from a file?

Postby HPW » Wed Aug 20, 2014 8:57 am

Hello,

Maybe you search for a GUID

search.php?st=0&sk=t&sd=d&sr=posts&keywords=guid

Regards
Hans-Peter
User avatar
HPW
 
Posts: 2510
Joined: Fri Apr 01, 2005 11:24 pm
Location: Germany

Re: Can NB get a unique identity from a file?

Postby dec » Wed Aug 20, 2014 9:00 am

Hello,

HPW wrote:Maybe you search for a GUID


I am not sure, Hans, however, this action can help in such case.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Can NB get a unique identity from a file?

Postby Enigman » Wed Aug 20, 2014 9:36 am

However, what kind of files you want to get/set the ID for?

I am working with an Access database.

Maybe you need to change your point of view, or, in other words, take another possible approach to do what you wanted.

LOL ... that's the point of my post. :D I am looking for any "good" way to accomplish this. I have preferences on how I want to do it, but I'll consider anything that works.

Maybe you search for a GUID

That depends. Where does the GUID come from? I couldn't find a description on either the hpw or np plug-in.

What I am trying to do is permanently associate some internal login data to the overall database file. That way if someone manually changes the login information, it will no longer be correctly associated with the overall database and I can programatically detect that. Like I mentioned, I can do this by embedding the ID in the database filename, which allows me to easily extract the ID at login time, but that is not the optimum way to do it. I would prefer something as an ID that is not generally seen by a user.

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Re: Can NB get a unique identity from a file?

Postby dec » Wed Aug 20, 2014 9:47 am

Hello,

Enigman wrote:Where does the GUID come from? I couldn't find a description on either the hpw or np plug-in.


Take a look at this Wikipedia article. Basically when you call the npGUIDStr you get a new unique GUID.
.
Enhance your NeoBook applications!
.
57 plugins, 1113 actions and 230 samples
.
NeoPlugins website: www.neoplugins.com
.
User avatar
dec
 
Posts: 1663
Joined: Wed Nov 16, 2005 12:48 am
Location: Spain

Re: Can NB get a unique identity from a file?

Postby Enigman » Wed Aug 20, 2014 10:22 am

Take a look at this Wikipedia article. Basically when you call the npGUIDStr you get a new unique GUID.

Okay, a GUID addresses the function of MAKING a unique ID, but I already have a method of doing that. The point of this thread is asking about a way to either EXTRACT an ID that is already present in the Access database when it is created by Windows MSJet, OR to be able to PLACE an ID in the Access database that cannot be easily seen by a user that manually opens the database using a hex editor or the Access program.

It really doesn't matter what the ID string is as long as it is reasonably unique. The ID could be "snarfblat-finsterwal". Doesn't matter. It just has to be infinitely repeatable when I extract the ID from the database, and it needs to MATCH the ID encrypted into the login controls. If I extract the login controls at database open time, decrypt the controls, and the ID in the login controls does not match the database ID, then I know that someone has hacked the login and I can fail the login with some appropriate "neener neener neener" message.

Maybe this will clarify. The process of creating a database from my app would be:

1) Prompt for a filename for the database.
2) Use the "create database" command to build the initial database.
3) Extract a pre-existing ID from the database header, OR, create an ID and embed it in the database.
4) Prompt the user for a username and password for the database.
5) Encrypt the username and password and database ID and deposit it in the database.

After that point, the database ID and the login data ID must always match. The point of all this is to prevent someone from blindly overwriting the encrypted login data with data from another database where the login username and password is already known.

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Re: Can NB get a unique identity from a file?

Postby Enigman » Wed Aug 20, 2014 10:32 am

I also have another post trying to solve login security from a completely different viewpoint.

See, "Need to have embedded login control data" in the "General Discussion" forum.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Re: Can NB get a unique identity from a file?

Postby Neosoft Support » Wed Aug 20, 2014 10:54 am

There is a Windows function called GetFileInformationByHandle that returns a fileindex which might work, but its not guaranteed to never change. For example, if you copy or move the file to another drive, the fileindex will change.

http://msdn.microsoft.com/en-us/library/aa363788(v=vs.85).aspx
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Can NB get a unique identity from a file?

Postby Enigman » Wed Aug 20, 2014 11:56 am

Neosoft Support wrote:There is a Windows function called GetFileInformationByHandle that returns a fileindex which might work, but its not guaranteed to never change. For example, if you copy or move the file to another drive, the fileindex will change.
http://msdn.microsoft.com/en-us/library/aa363788(v=vs.85).aspx

Well, that's much closer to what I want. However, I would probably use the creation date/time over the fileindex. The fileindex would change if the user copies or moves the database to another drive or directory, while the creation date is less likely to change, and creation dates should never repeat on the same PC. If I want to test this, how would I impliment the GetFileInformationByHandle Windows function in NeoBook?

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Re: Can NB get a unique identity from a file?

Postby dpayer » Wed Aug 20, 2014 1:19 pm

Windows has an identifier for the file built into the file system that will display the version of the file. Of course, it has to be written to the file when saving it but it can be retrieved.

Here is a VBS script to look at: http://stackoverflow.com/questions/1422 ... g-a-script

I have also created a FileManager replacement that incorporates file/folder functions I created that you can look at here which displays that information about the files, including the version number. You can look at the code I created and see if it is helpful. You will have to find out how to write the version number for a file elsewhere.

viewtopic.php?t=19555

What you can get from the script/function I used:
Image

David P.
Last edited by dpayer on Thu Aug 21, 2014 2:42 pm, edited 2 times in total.
David Payer
Des Moines, Iowa
USA
User avatar
dpayer
 
Posts: 1380
Joined: Mon Apr 11, 2005 5:55 am
Location: Iowa - USA

Re: Can NB get a unique identity from a file?

Postby Neosoft Support » Thu Aug 21, 2014 10:42 am

...If I want to test this, how would I impliment the GetFileInformationByHandle Windows function in NeoBook?


You can look for some VBScript and create a function. Otherwise, you would need to create a custom plug-in.
NeoSoft Support
Neosoft Support
NeoSoft Team
 
Posts: 5593
Joined: Thu Mar 31, 2005 10:48 pm
Location: Oregon, USA

Re: Can NB get a unique identity from a file?

Postby Enigman » Thu Aug 21, 2014 11:05 am

Neosoft Support wrote:You can look for some VBScript and create a function. Otherwise, you would need to create a custom plug-in.

Okay, thanks. Sooo not gonna do that, though, just for this one thing. I was hoping maybe there was a script lying around that does it. I think I have a workaround using just the database content, and unlike the create date or file index, the workaround will never change. We'll see after testing. :wink:

Thanks.
User avatar
Enigman
 
Posts: 314
Joined: Tue Apr 12, 2005 3:57 pm
Location: Foothill Ranch, CA

Next

Return to General NeoBook Discussions

Who is online

Users browsing this forum: No registered users and 2 guests