|
I would like to generate human friendly product keys similar to what Microsoft and many others do. The keys should have the property of being 25 or 30 characters.
I need to be able to generate many individual keys, on the order of 10000 or so probably.
They should be generated in such a way that it is easy to verify that a particular key is one which I generated, but hard for someone else to generate the identical list of keys. I am aware of commerical products that do this, but it seems like something that wouldn't be that hard to reinvent.
It appears to me that this requirement calls for use of an asymmetric crypto algorithm.
Like all locks, this one is intended to help honest people stay honest. I'm not too worried about the hacker with a disassembler, but it ought to be at least challenging for him to generate a valid product key.
Any suggestions, especially pointers to sample code, will be greatly appreciated.
Jim
|
|
|
|
|
this might work:
assuming you're using RSA (or something similar):
1. come up with a public/private key pair.
2. put one of your keys in your app, and one in your license creator.
3. generate a series of short plaintext strings like this: "SomeText_######" , where ###### is an incrementing counter, or a time stamp, or some other unique value (just to ensure that no two codes are the same). the actual content doesn't matter to the algorithm, only that the form of the string can be verified when decoded.
4. encrypt each of those strings with your license creator key. then output them as hex strings: a0b4-d3ee-091c-etc. the code length will depend on how big the input data was.
5. distribute those keys to your users.
6. when your app gets a license code, decrypt it using the key from #2.
7. if the decrypted code matches the form from #3, it's a valid license code.
take a look at crypto++[^].
Software | Cleek
|
|
|
|
|
That's a good idea, but I have a question about step #5, "distribute those keys to your users".
I would like to have a fixed length key of no more than 30 characters, similar to what microsoft does. I'm not sure that's feasable if the key is just hex strings. I guess I don't grock the relationship between the lenght of the plantext and the lenght of the cyphertext.
Perhaps I should encode the key with a base 26 system.
I already incorporate parts of crypto++ in my app for symmetric encryption, it is an excellent product.
|
|
|
|
|
Jim Howard wrote:
I guess I don't grock the relationship between the lenght of the plantext and the lenght of the cyphertext.
i believe RSA requires the block size to be the same as the key length. so, a 32 byte code string, based on 16 hex numbers, gives you a 128-bit key - not very big.
Jim Howard wrote:
Perhaps I should encode the key with a base 26 system
or base32. it gives you an extra byte of data for every 8 code charaters vs base16. (8 chars b32 = 40 bits. 8 chars b16=32 bits)
Software | Cleek
|
|
|
|
|
I search to know (in C++ & MFC) when a windows is finished to be move or resizing. To repaint it only at the end, not durin event.
Can you help me
Thank
Thierry
|
|
|
|
|
Only the user knows.
(The user is the warm thing attached to the mouse.)
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
you can make a heavy overload of WM_LBUTTONDOWN , WM_LBUTTONUP and WM_DRAGANDDROP (or something like that) with a set of flags to try to know if, when the mouse button is getting up, it is the end of your resizing/moving action.
have a good (head)-day (headache... muwahahahh )
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
If your client calls your child window properly, and you implement your child window properly, you might find this one useful: WM_SETREDRAW
However, if you are a top level window, then maybe you can watch for WM_WINDOWPOSCHANGING, block your drawing, and then perform all your drawing when you get the WM_WINDOWPOSCHANGED.
The WM_WINDOWPOSCHANGING message is sent to a window whose size, position, or place in the Z order is about to change as a result of a call to the SetWindowPos function or another window-management function. The WM_WINDOWPOSCHANGED message is sent to a window whose size, position, or place in the Z order has changed as a result of a call to the SetWindowPos function or another window-management function.
Also read these two : WM_ENTERSIZEMOVE and WM_EXITSIZEMOVE
|
|
|
|
|
Fine, Thank you I try that.
|
|
|
|
|
How can I make this message box work?
<br />
CString * s = (CString *)lParam;<br />
AfxMessageBox(s);<br />
delete s;<br />
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
AfxMessageBox does not take a CString * parameter.
Assuming lParam really is is CString * try:
...
AfxMessageBox(*s);
...
The opinions expressed in this communication do not necessarily represent those of the author (especially if you find them impolite, discourteous or inflammatory).
|
|
|
|
|
Sorry, I guess I needed more detail
Here is the whole function:
<br />
LRESULT CLAMsgSwDlg::OnMyConnect(WPARAM, LPARAM lParam)<br />
{<br />
CString * s = (CString *)lParam;<br />
AfxMessageBox(s);<br />
delete s;<br />
return 0;<br />
}<br />
I've tried it that way and I still get an error. But after stepping thru it I found that I was getting an error on the "delete s;". So thanks for that help...now another question. Am I not supposed to delete this pointer so that it does not hold memory and become a leak?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
s ( via lParam ) is not allocated by you, so you don't have to delete it yourself; should be done by the one who initiate the message.
Maximilien Lincourt
Your Head A Splode - Strong Bad
|
|
|
|
|
I'm trying to send back a pointer to a CString from a thread that I am creating.
After my thread connects to socket sever and a call is made to the OnConnect event then I send message to the main app and pass a pointer to some data.
<br />
void CMyThread::OnConnect()<br />
{<br />
MessageBox(NULL, "OnConnect", "CMyThread", MB_OK);<br />
CString threadID = "TESTER";<br />
if (!PostMessage(myHandle->m_hWnd, UWM_CONNECTED, 0, (LPARAM)&threadID))<br />
MessageBox(NULL, "Error Posting Connection Message", "Error on PostMessage", MB_OK | MB_ICONEXCLAMATION);<br />
}<br />
then in my main app I want to do something with the data, (for testing purposes, I just pop up a message box with the data sent) when it's received by my main app. But all i get is, I assuming the pointer handle to the CString of the pointer from my thread....and it's garbage when I show it thru afxmessagebox.
<br />
LRESULT CLAMsgSwDlg::OnMyConnect(WPARAM, LPARAM lParam)<br />
{<br />
CString * s = (CString *)lParam;<br />
AfxMessageBox("Here in my main app");<br />
AfxMessageBox(*s);<br />
return 0;<br />
}<br />
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
You are running into scope problems. The CString threadID is going out of scope, and being destroyed, at the end of your OnConnect() method. As a result, the pointer that is recieved by the OnMyConnect() method is no longer valid.
"You're obviously a superstar." - Christian Graus about me - 12 Feb '03
"Obviously ??? You're definitely a superstar!!!" mYkel - 21 Jun '04
Within you lies the power for good - Use it!
|
|
|
|
|
OHHH!! I see what you are saying. That threadId is getting destroyed as soon as I leave the onConnect function.
Okay so how can I keep it in scope until my main app receives the data?
Thanks
Tom Wright
tawright915@yahoo.com
|
|
|
|
|
Tom Wright wrote:
I'm trying to send back a pointer to a CString
is CString::Format() function help ?
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
hello all,
i m hving a problem with CSpinButtonCtl object. It is attached to a RichEdit box. i m using a button to update the values from the rich edit box. the problem is whenever i click on the spin control arrows using mouse the values get updated properly. but whenever i use arrow keys the value shown in the text box is proper but after i update it is showing the old values itself. i hv clicked on the property use arrow keys. please help me as this is very urgent
regards,
poornima
|
|
|
|
|
I've just started to learn this high resolution multimedia timer. I have a question regarding to timeSetEvent function.
MMRESULT timeSetEvent(
UINT uDelay,
UINT uResolution,
LPTIMECALLBACK lpTimeProc,
DWORD_PTR dwUser,
UINT fuEvent
);
I want my timer to be TIME_PERIODIC (e.g. fuEvent=TIME_PERIODIC). I want to be able to specify: fire the timer at this particular timer
point t0, then repeatedly fire the timer after every n miliseconds.
Is there a way to make timeSetEvent do so? After setting time event, it should wait now.getmilisec() - t0.getmilisec() to be fired, then repeatedly fires the timer every n miliseconds.
The uDelay field seems to only provide the interval, not the actual time point to fire the timer.
Please feel free to correct me if I'm wrong. Thanks in advance for any help.
Regards,
|
|
|
|
|
Has anyone made any source code for SATO printer? I'm having trouble setting up the code for printing the label with XP version.
my code shown below: (was made in Borland Builder but its in c++ code though.)
void __fastcall TLabel_Test::btnPrintClick(TObject *Sender)
{
DWORD numsent;
OVERLAPPED overlapped;
char LabelString[500];
char *Port = "LPT2";
strcpy(LabelString, "A");
strcat(LabelString, "V25H380OB");
strcat(LabelString, "20041201152631");
strcat(LabelString, "V25H750XU");
strcat(LabelString, "Mgr: 2130");
strcat(LabelString, "V40H750XU");
strcat(LabelString, "DLL: 1125");
strcat(LabelString, "V80H250XU");
strcat(LabelString, "Print Count > 25000");
strcat(LabelString, "V105H250XU");
strcat(LabelString, "Print Count > 25000 *");
strcat(LabelString, "V130H250XU");
strcat(LabelString, "Print Count > 25000");
strcat(LabelString, "V155H250XU");
strcat(LabelString, "Print Count > 25000");
strcat(LabelString, "V180H250XU");
strcat(LabelString, "Print Count > 25000 *");
strcat(LabelString, "V205H250XU");
strcat(LabelString, "Print Count > 25000");
strcat(LabelString, "V230H250XU");
strcat(LabelString, "Print Count > 25000 *");
strcat(LabelString, "Q1Z");
Retry:
HANDLE hCom =
CreateFile(Port,GENERIC_READ|GENERIC_WRITE,NULL,NULL,OPEN_EXISTING,FILE_FLAG_OVERLAPPED,NULL);
if(hCom == INVALID_HANDLE_VALUE)
{
edtStatus->Text = "Error. Printer Offline";
return;
}
WriteFile(hCom, LabelString, strlen(LabelString), &numsent, &overlapped);
WaitForSingleObject(overlapped.hEvent, 1000);
GetOverlappedResult(hCom, &overlapped, &numsent, FALSE);
CloseHandle(hCom);
if(numsent < strlen(LabelString))
{
edtStatus->Text = "Error. Printer Offline";
return;
}
}
|
|
|
|
|
I am trying to paint some text in a window and have it change colour when the mouse is over it, I am using the code:
case WM_PAINT:
{
HFONT pOldFont;
char *szBuffer;
CRect rcClient;
PAINTSTRUCT ps;
COLORREF col;
HFONT hNewFont;
BITMAP bm;
HDC hDC = BeginPaint(data->m_hWnd, &ps);
HDC hdcMem = CreateCompatibleDC(hDC);
HBITMAP hbmOld = (HBITMAP)SelectObject(hdcMem,m_biBackground);
GetObject((HBITMAP)>m_biBackground, sizeof(bm), &bm);
BitBlt(hDC, 0, 0, data->m_nWidth, data->m_nHeight, hdcMem, 0, 0, SRCCOPY);
SetBkMode(hDC, TRANSPARENT);
rcClient.DeflateRect(10,20,10,20);
if (m_bMouseIsOver)
{
col = RGB(GetRValue(m_crSelected),GetGValue(data->m_crSelected),GetBValue(data->m_crSelected));
hNewFont = (HFONT)data->m_hSelectedFont;
}
else
{
col = RGB(GetRValue(data->m_crNormal),GetGValue(data->m_crNormal),GetBValue(data->m_crNormal));
hNewFont = (HFONT)data->m_hNormalFont;
}
szBuffer=new char[strlen(data->m_strCaption)+10];
strcpy(szBuffer,m_strCaption);
pOldFont=(HFONT)SelectObject(hDC, &hNewFont);
SetTextColor(hDC, col);
DrawText(hDC, szBuffer,-1,data->m_rcText,DT_CENTER | DT_VCENTER | DT_WORDBREAK | DT_END_ELLIPSIS);
delete[] szBuffer;
SelectObject(hDC, pOldFont);
SelectObject(hdcMem, hbmOld);
DeleteDC(hdcMem);
EndPaint(data->m_hWnd, &ps);
return 0;
}
I can see that it is selecting the correct colour because the variable 'col' contains the right value at the right time.
But the text displayed is always the first colour, I must be missing something simple, any ideas what???
|
|
|
|
|
OK guys well im sorta finished with my final project but i cant get it to work CORRECTLY. The program is to have a menu and ask the user to choose betweetn add, subtract, mult and divide. when they choose whatever one it will ask them a simple question. and if they get the correct answer or wrong answer it will ask them again if they want another problem. If they choose yes then it will give em another problem but if they choose no it will go back to the menu. I cant seem when they enter no it keeps say "enter another seed vaule" I want it to go back to the menu. Well here is the code. O and if they enter anything besides Y or N i need it to say sorry that is an incorrect choice. Here is the code:
#include
#include
#include
using namespace std;
int main()
{
int choice; float num1, num2, answer, correct;
char again;
unsigned seed;
do
{
cout << "\n\t\tSimple Math Tutor Menu\n\n";
cout << "1. Addition\n";
cout << "2. Subtraction\n";
cout << "3. Division\n";
cout << "4. Multiplication\n";
cout << "5. Quit The Program\n\n";
cout << "Please enter a choice: ";
cin >> choice;
if (choice <1 || choice >5)
{
cout << "Sorry that is an incorrect choice!"<<endl;
cout <<="" "please="" enter="" another="" choice="" "<<endl;
cin="">> choice;
}
cout<<"Enter a seed value: ";
cin>>seed;
srand(seed);
num1 = 1 + rand() % 10;
num2 = 1 + rand() % 10;
switch (choice)
{
case 1 : do
{
cout << "What is the sum of "<< num1 << " and " << num2 <<endl;
cin>> answer;
correct = num1 + num2;
if ( answer == correct)
{
cout << "Congratulations you are correct!" <<endl;
}
else
{
cout="" <<="" "sorry="" that="" was="" incorrect"="" <<endl;
cout="" "the="" correct="" answer="" was:="" "="" <<endl;
}
cout="" "would="" you="" like="" to="" do="" another="" problem="" (y="" n)?="" ";
cin="">> again;
cout<<"\nEnter another seed value: ";
cin>>seed;
num1 = 1 + rand() % 10;
num2 = 1 + rand() % 10;
}while (again=='y' || again=='Y');
if (again != 'y' || again !='Y')
cout << "Sorry That is an incorrect choice" <
|
|
|
|
|
James1985 wrote:
cin>>seed;
num1 = 1 + rand() % 10;
num2 = 1 + rand() % 10;
Why twice ??
Why not remove the bottom lines?
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Papa wrote:
cin>>seed;
num1 = 1 + rand() % 10;
num2 = 1 + rand() % 10;
Why twice ??
Why not remove the bottom lines?
because one affects num1, and another affects num2.
num1 might be different of num2 , but only if srand() if called...
why srand(seed) is not called after the cin... sorry, don't know.
TOXCCT >>> GEII power [toxcct][VisualCalc]
|
|
|
|
|
i write a dialog with a skin.The dialog has no style of SYSTEM_MENU,therefore, it has no menu when you click the minimized icon on the task bar.How to pop up it?
please contact:
max_xiayi@hotmail.com
|
|
|
|
|