|
What version of workshop? Workshop < 5 does not have any STL, in which case you'll need the stlport mentioned above. If you have Workshop 5+ then STL is bundled with this, and your installation must be screwed. I dont have access to a sparc at the moment, but from memory the STL files are located somewhere within the workshop directory (/opt/SUNWspro is likely), and they dont have .h extensions either!
|
|
|
|
|
yes i was using 4.2 and it did not work..I tried the same on a box with 6.0 and yippeeee!!!! it is working like crazy !! thanks a lot anonymous..thanks a ton..
There are no failures; there are only extended learning opportunities.
|
|
|
|
|
Hi,
I'm looking for some help in developing a PIN generation algorithm for scratch cards. What I would like to do is take a range of "control numbers" (a sequential number representing a batch of PINs) and generate a 10-14 digit PIN based on that. I'm not looking for a random number generation, but something that will generate a pseduo-random number based on the control number. To further complicate the issue, the PINs would need to be unique over a large range control numbers (1M+).
I've experimented with different operations like MOD and shifting and I get a nice range of random PINs. But I cannot seem to figure out how to make the number unique over the range I'm looking for. I know it can be done but the math to develop / prove it is beyond me.
And suggestions or references would be appreciated. I understand that something like this is very propriety to a business so I'm not necessary looking for a complete solution, just a point in the right direction.
Below is an example of what I'm trying to do. Thanks in advance for the help,
David
Control # PIN
00000001 123.456.789.123
00000002 638.098.270.748
00000003 472.309.327.732
0000nnnn 852.382.127.034
|
|
|
|
|
you could just encrypt the control # with a cipher of some kind (there are a few here on CP). the output of a cipher is guaranteed to be unique - it has to be, if it can decrypt the encrypted data back to the correct input. personally, i would use a stream cipher (of which i don't see any on CP), since it eliminates the need for input padding. but, a block cipher will work, too.
so:
PIN = Encrypt(Control#)
where the control # has at least as many bits as the PIN.
-c
Zzzzz...
|
|
|
|
|
Interesting solution, I'll definitely take a look into it. Thanks for the quick reply.
D
|
|
|
|
|
Actually, it sounds like what you want is more of a one-way hash. I'm guessing that you don't need to be able to determine the control number from the PIN?
If you don't, check out one-way hashes. The one that comes to mind is MD5, but I know there are other more modern ones.
J
May the bear never have cause to eat you.
|
|
|
|
|
You are correct, another excellent suggestion.
|
|
|
|
|
a hash function doesn't guarantee that Hash(X) != Hash(Y), only that it's hard to find another input whos hash is the same as Hash(X).
-c
Zzzzz...
|
|
|
|
|
note that a one way hash doesn't fulfill his requirement that the PIN is unique. there can be hash collisions.
a hash only makes it difficult to find a second stream M' whos hash is the same as the first stream, M. the goal of a good hash function is to make the computation of M' based on the hash computationally infeasible.
-c
Zzzzz...
|
|
|
|
|
Chris Losinger wrote:
note that a one way hash doesn't fulfill his requirement that the PIN is unique. there can be hash collisions
Granted... Hmmm. I guess it depends on what the application is, because in a secure situation, I wouldn't want there to be an algorithm that would take a PIN and generate the control ID.
Can't even use a PRNG with period 1 million... because it would repeat numbers.
I guess what you need is a collision-less hash for your specific input size (1 million) - that is, an algorithm guaranteed (sp?) not to repeat itself within the first N inputs...
J
May the bear never have cause to eat you.
|
|
|
|
|
Jamie Hale wrote:
I guess what you need is a collision-less hash
you could do this by tracking which PINs have been issued - then check for collisions. if you find one, adjust the input or the hash as necessary until the collision goes away.
if storing PINs is not security-smart, then store hashes of the PINs and check for collisions on the hashes of the PINs. (it start to get ugly trying to figure out how many bits you need to handle all or your input range )
-c
Zzzzz...
|
|
|
|
|
Using the cipher is working great, I've implemented a quick test using Rijndael. Now I'm trying to get a large sample w/o repeats. I'm up to 250K so far. I'll just need to keep playing with the keys and I'll get there.
The drawback with a hash is security - once someone figured out the algorithm then all PINs would be subject. While the same is true with a cipher, the cipher give a larger "randomness".
Thanks again for the help, you have given me just what I needed.
David
|
|
|
|
|
Anyone have a recommendation for an OLE DB or ADO class to access MS SQL Server? Was using Carlos Antollini v2.07, but now I need one without MFC.
|
|
|
|
|
Hi friends!!!
I've created a simple program, the main function of my program starts another thread and itself remain busy doing other things. Now at some point, my main program wants to "terminate" the thread "immediately" no matter whatever thread was doing. The problem is that my thread function uses lots of new/delete and regularly calls other functions that allocates/deallocates memory from the heap. I feal that if main program interrupt this thread in between using TerminateThread(), there may be memory leakages.
But i want my main program to exit this thread "immediately" and "gracefully"..what do you suggest ???
|
|
|
|
|
CreateEvent, SetEvent, WaitForSingleObject
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Ted Ferenc wrote:
CreateEvent, SetEvent, WaitForSingleObject
No, this is not my problem. My thread is running and its parent thread want to terminate it "immediately". For this purpose, the parent thread can use TerminateThread() API. But the child thread might have allocated memory from the heap that it had not deallocated and parent thread terminating this child in such a manner, can cause memory leaks
|
|
|
|
|
For a graceful shutdown you do NOT want to use TerminateThread. TerminateThread should only be used as a last resort. You should Create an "kill" event in the thread and set it in the main application and test it every once and a while in the thread.
John
|
|
|
|
|
As John says create a kill event, you won't just get memory leaks, but you could get an exception as well!
Just raise a kill event and use WaitForSingleObject on the thread handle with, say a 5 second timeout, only a very last resort use TerminateThread()
If I have seen further it is by standing on the shoulders of Giants. - Isaac Newton 1676
|
|
|
|
|
Theres a CP project :
http://www.codeproject.com/docking/ToolbarWithCombo.asp
which has either a regular combobox being created in the toolbar or a CSmartComboBox (derived from CComboBox).
However
BOOL CreateComboBox(class CComboBox& comboBox, UINT nIndex, UINT nID, int nWidth, int nDropHeight);
has class CComboBox in it. Can I pass in a SmartComboBox variable instead? Or do I have to modify the function to:
BOOL CreateComboBox(class CSmartComboBox& comboBox, UINT nIndex, UINT nID, int nWidth, int nDropHeight);
?
The second question is : why the word class in class CComboBox& comboBox ??? Cant it just be:
CreateComboBox(CComboBox& comboBox,...) withgout the word class?
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
...has class CComboBox in it. Can I pass in a SmartComboBox variable instead?
Yes, so long as SmartComboBox is derived from CComboBox.
ns wrote:
Cant it just be:
CreateComboBox(CComboBox& comboBox,...) withgout the word class?
Yes.
cheers,
-B
|
|
|
|
|
MAny thanks! That helps!
Appreciate your help,
ns
|
|
|
|
|
Got a quick question the following code works in the OnInitDialog function of CPropertySheet, however the same code does nothing in the OnInitDialog function of the CPropertyPage?
// CPropertySheet OnInitDialog code
CRect rect;
CPropertyPage *pPage = GetActivePage();
pPage->GetWindowRect(&rect);
ScreenToClient(&rect);
rect.right += 50;
rect.bottom += 50;
pPage->MoveWindow(&rect);
// CPropertyPage OnInitDialog code
CRect rect;
GetWindowRect(&rect);
ScreenToClient(&rect);
rect.right += 50;
rect.bottom += 50;
MoveWindow(&rect);
Now i know it shouldn't matter to me cause i got it working in the sheet, but it's driving me crazy knowing that this should work in each individual page as well!! Help me understand this craziness
|
|
|
|
|
WHy do they have tbbs_separator in the following in the CP article:
SetButtonInfo (0, ID_EDIT_R, <code>TBBS_SEPARATOR </code>, <code>cxChar * 8</code>);
GetItemRect (0, &rect);
http://www.codeproject.com/docking/spnsld.asp
FRom MSDN:
void SetButtonInfo(
int nIndex,
UINT nID,
UINT nStyle,
int <code>iImage </code>);
THe fourth parameter is puzzling me too.....they are two different things...cxChar * 8
looks like a width, not an image index....
Appreciate your help,
ns
|
|
|
|
|
ns wrote:
cxChar * 8
is the width of the separator
Gary Kirkham
A working Program is one that has only unobserved bugs
I thought I wanted a career, turns out I just wanted paychecks
|
|
|
|
|
TBBS_SEPARATOR indicates the use of an separator. Then it's size is widened to have place for inserting other elements. This is the common method for placing custom items like combo boxes etc. on a toolbar.
|
|
|
|