Jerry said:
I need to be able to generate unique names for files. I was
considering that hash alogorithms, but if I had two files with the
same name, I'd get the same hash. I am collecting and storing files
and I want to store them all in the same directory and I want the
names to be cryptic and unique. Any thoughts?
I needed to do this in the VB3 / 8.3 era for an image capture program.
There was the possibility of many images from many computers on any given
day, so I came up with a base-36 naming system something like this. BTW,
it's been a long time ago so please don't flame for math errors. <g>
Base 36 code:
0 = 0
1 = 1
....
9 = 9
A = 10
B = 11
....
Z = 36
The 8 part of the 8.3 filenames were of this form:
YMDZZXXX
Y -- Year. 0 = 1990, 1=1991, ..., Z = (1990 + 36)
M -- Month. 1 = Jan, 2 = Feb, ... (1-based for ease of reading)
D -- Day 1 = 1, ... (1-based for ease of reading)
ZZ -- "Assigned Computer Number" 36 * 36 possibilities
XXX -- Sequence #. 36 * 36 * 36 possibilities
The program looked in an ini file for the next sequence # for that day,
generated the 8 part of the 8.3 filename, checked the directory, if already
existed incremened & tried again, repeatedly until ZZZ+1 before failing,
saved the full 8.3 (JPG, TIF, WSQ or BMP), updated the ini file.
It worked well. Images captured in the mid 1990's are still part of a
fingerprint biometric test database, I believe.
I think it would satisfy your "cryptic and unique" requirements. <g>
-- Mark