|
Check bo2k code
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
I'm implementing RSA for the first time. Err...don't ask why I'm doing what's already been done , but it's for my internship.
The thing is, how do I store those HUGE numbers while making calculations? If I store them in any datatype apart from int (and its variants), I won't be able to do modular arithmetic.
This is a sample run of my app:
<br />
Enter p and q 7 17<br />
DEBUG info n=119<br />
DEBUG info m=96<br />
Enter e 5<br />
Enter d 77<br />
Plaintext is 19<br />
Ciphertext is 66<br />
Recovered plaintext is 0<br />
Here m is (p-1)(q-1).
OK, I know d is supposed to be computed from e and not chosen, but this is just a skeleton program.
Oh, yeah, I'm doing it on Win2K with VS 6.0 if it makes any difference.
Thanks,
Vikram.
"There's probably a Nish-like alien answering VB questions on a CP forum as we speak." - adamUK in The Lounge, discussing aliens and parallel universes.
"Do not give redundant error messages again and again." - A classmate of mine, while giving a class talk on error detection in compiler design.
|
|
|
|
|
Maybe a LARGE_INTEGER could be your way?
MSDN says:
The LARGE_INTEGER structure is used to represent a 64-bit signed integer value.
Regards,
BB
|
|
|
|
|
RSA needs integers with thousands of bits.
|
|
|
|
|
There is no VC-standard integer variable of that capacity. Write your own or use an existing implementation from the Net.
Regards,
BB
|
|
|
|
|
Bartosz Bien wrote:
The LARGE_INTEGER structure is used to represent a 64-bit signed integer value.
64 bits == 20 digits, even if it's unsigned. I need something like 120 digits, prolly much more. I'll try a third-party library. If all else fails, I'll have to go for Java. I think there's a good huge integer library for Java.
Vikram.
"There's probably a Nish-like alien answering VB questions on a CP forum as we speak." - adamUK in The Lounge, discussing aliens and parallel universes.
"Do not give redundant error messages again and again." - A classmate of mine, while giving a class talk on error detection in compiler design.
|
|
|
|
|
You need a class for handling arbitrary-precision integers ("bignums"). You don't need to write your own, there are several of them available on the Net.
|
|
|
|
|
hi,
quick question about the pointer NULL. witch adress value does it have? does it happen to be 0xcccccccc?
thnx,
willem
[]D [] []D []
|
|
|
|
|
sorry already got the solution, 0xcccccccc is the point adress value of a undefined pointer(standart value). i forgot the define my pointer before getting values from it. dumb dumb
thnx anyways
[]D [] []D []
|
|
|
|
|
Willem B wrote:
0xcccccccc is the point adress value of a undefined pointer
Actually, 0xCCCCCCCC is a defined value meaning uninitialized pointer. This is done on purpose by the compiler in debug mode so that you'll know when an uninitialized pointer is being referenced.
|
|
|
|
|
why didn't my compiler told me that;) stupid machine ;P
[]D [] []D []
|
|
|
|
|
What warning level are you using?
|
|
|
|
|
What do you understand by "address value"? In most compilers, a null pointer, when converted to a number (an int , for instance), yields 0. Strictly speaking, this does not mean that a null pointer point to the address 0x00000000 (the standard marks as undefined conversion from pointers to integral values), although for some purposes you can assume this.
Joaquín M López Muñoz
Telefónica, Investigación y Desarrollo
|
|
|
|
|
Hi,
i made this "File save as.." dialog window but after this i don'really know how to insert or to connect the given name to my saving function which is in another dialog window?
CString szlstfile = fileDlg.GetPathName(); //MainFrm.cpp
SaveStream(szlstfile); //ContrDlg.cpp
Thanks, Mark
|
|
|
|
|
either open the File SAve as from ur dialog or make a member variable, and set it from the outside using a reference or a pointer to ur dialog
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
Hmm, sounds tricky..
I make a member variable(m_filename). Do u have a code snip for that?
Thanks, Mark
|
|
|
|
|
in ur class:
class urClass
{
private:
CString m_fileName; /*(or array of char)*/
public:
void SetFileName ( CString fileName ) ;
};
and from another part of the world where this compile:
urClass object;
...
object.SetFileName ( "whateverPathToSet" ) ;
Papa
while (TRUE)
Papa.WillLove ( Bebe ) ;
|
|
|
|
|
What you have looks fine. Presumably SaveStream() will do something with the filename passed to it. What seems to be the problem?
|
|
|
|
|
Hi,
the problem is to pass the filename from MainFrm.cpp to ControlDlg.cpp
Thanks, Mark
|
|
|
|
|
Passing variables from one file to another is undefined. I assume you have a class defined in ControlDlg.cpp (e.g., CControlDlg) with at least one public method (e.g., SaveStream). In your CMainFrame class, you'll need an instance of the CControlDlg class, unless the method is static. Now it's just a matter of calling the CControlDlg's method, passing it the filename obtained from CFileDialog.
|
|
|
|
|
Yes, thats right. I like to give the filename before data arrived.(it comes from the usb-port). The SaveStream() func is called during runtime when data arrives.
How i can do that? I think the filename(variable is stored in RAM)..
Thanks, Mark
|
|
|
|
|
Now you've really got me confused. In your OP, the filename was originally coming from CFileDialog::GetPathName(). You then wanted to pass that to the SaveStream() function.
Perhaps you could explain in detail what you are after rather than just offer bits and pieces that just get construed along the way.
|
|
|
|
|
I am sorry but thanks for your time.
----------------------------------------------------------------------------
//MainFrm.cpp
void CMainFrame::OnDataSaveAs()
{
CFileDialog dlg(FALSE);
CControlDlg cd;
dlg.m_ofn.lpstrInitialDir = "F:";
dlg.DoModal();
if ( dlg.DoModal() == IDOK)
{
CString filename = dlg.GetPathName();
cd.SaveStream(filename); //doesn't work because no data at start
}
}
-----------------------------------------------------------------------
//ControlDlg.cpp includes the main code for scanner
void CControlDlg::OndataReady(LPUNKNOWN pDobj)
{
STGMEDIUM s;
long hint = 0L;
BOOL r = FALSE;
COleDataObject foo;
foo.Attach((LPDATAOBJECT)pDobj);
r = ReadStream(pDobj, s, foo);
if(r){
SaveStream(filename); //saving
}
}
I like the user to choose a filename when my app starts, because this is a control programm for a 3d scanner over USB. When my app starts the scanner takes some scans every few seconds. So if the user select a filename at the start there is no data for the file at the begining.
When the scanner sends the datafiles i like to save them incremently.
For example:
filename choosen is "File", then saved as:
File_1
File_2
File_3
....
..for this the prog has to know the last filename. This all i have to handle.
|
|
|
|
|
I assume that OnDataSaveAs() is called when the "Save As" button is clicked, or when the "Save As" menu option is selected. Since this is a user-defined action, it may not have happened by the time your program needs the name of an output file (i.e., when calling SaveStream() from within CControlDlg::OndataReady().
It sounds like you need to check for the existance of an output filename before saving the data. Something like:
CControlDlg::OndataReady()
{
...
if (filename.IsEmpty() == TRUE)
{
CFileDialog dlg(FALSE);
dlg.DoModal();
filename = dlg.GetPathName();
}
...
SaveStream(filename);
}
You may need to remove like code from the CMainFrame::OnDataSaveAs() function.
|
|
|
|
|
Thanks for all. I will try it out.
|
|
|
|