Hi, probably not the best place for this but maybe someone can help.
For one of my programs i'm trying to impliment my own version of the RSA algorithm, the encryption works fine, however the decrption does not, even though it uses basically the same algorithm. The code is as follows:
// g++ main.c -o main<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include "math.h"<br />
int do_crypto(int M, int e, int N);<br />
int main()<br />
// TWO PRIMES FOR OUR KEY<br />
int p = 17;<br />
int q = 11;<br />
// THIRD PART OF OUR KEY (PUBLIC)<br />
int e = 7;<br />
// CALCULATE THE OTHER PART OF THE PUBLIC KEY<br />
int N = p * q; // = 187<br />
// THE CHARACTER TO ENCODE AS ASCII<br />
int M = 88;<br />
//int M = "M";<br />
// ENCRYPT A CHARACTER<br />
//int C = int ( M * exp(e) ) % N;<br />
int C = do_crypto(M, e, N); // int M, int e, int N)<br />
printf("C = %d \n", C);<br />
// CALCULATE THE DECRYPT KEY<br />
//int d = ( 1 % ( (p-1) * (q-1) ) ) / e;<br />
int d = ( ( (p-1) * (q-1) ) / e );<br />
printf("d = %d \n", d);<br />
// DECRYPT THE CHARACTER<br />
int m = do_crypto(11, 23, 187); // int C, int d, int N)<br />
printf("m = %d \n", m);<br />
return 0;<br />
int do_crypto(int M, int e, int N)<br />
int iret = int ( M * exp(e) ) % N;<br />
return iret;<br />
When decrypting I have put in actual values for the keys etc, and the result should be 88.
The actual formulas are:
ENCRYPT: C = Me (Mod N)
DECRYPT: M = Cd (Mod N)
*** Please note the 'e' and 'd' are supposed to be superscript, e.g. raised to the power of...
I am starting to develop application in Visual C++ .Net (Visual C++ 8.0).
I made a little project and now I want to make an executable file which it could be copied in a different computer or folder without install it or without copy any DLL, I want to copy just the executable.
I was trying to configure the project option but I failed.
When I worked with Visual Studio 6.0 (Visual C++) I could set the link option like static so I could copy the exe file in different folders or computers
i mean, you use MFC, Win32 or such libraries which generate natice code (directly for the target microprocessor), or using managed code, which is actually an intermediate language for the .NET framework...
we have an older application that we would like to extend with managed code (written in c#). The extension was planned to be through a dll written in C++ that would call managed part - as proposed in the following article: http://www.codeproject.com/dotnet/bridge.asp
problem is that when I write a simple non-managed app in VC2005, I can call managed part without any problem, but when I try to call it from the same application compiled with VC6, it simply breaks.
here is the C# assembly code:
public class Class1
public static int ShowDialog(string sText, string sCaption)
here is the wrapper C++ dll
using namespace System;
using namespace ClassLibrary1;
using namespace System::Windows::Forms;
This works if it is compiled in VS2005 but breaks when compiled in VC6 (unhandled exception in console2.exe (KERNEL32.DLL): 0xE0434F4D:(no name).)
Unfortunately it is not possible to recompile the old application with VC2005 since it is pretty old application with a lots of code written in cobol.
This may be a newbie question or has been discussed before, but I searched the message boards and could't find anything similar. I am not sure at all that it is possible to connect unmanaged code with managed code this way. Am I on the right track? Tnx in advance
VC6 has no support for the .NET platform (managed code), you must use later compiler.
I know that, but it was my understanding that functions prefixed with extern "C" will be visible (and callable) as simple C functions. I expected to be able to call them as any other dll that exports some functions and structures.
led mike wrote:
And you compile Cobal with VC6?
No, actually the application we have is an old cobol application now largely extended and partly replaced with code written in VC6. Cobol can call VC6 dlls, so I thought it could also call dlls written in VS2005 - as long as the functions are exported with extern "C" prefixes. When I didn't succeed in that, I tried to call a dll from program written with VC6 only to find that is not possible, too.
Can anybody help me to get Icon details like its name, target path, working directory whenever it is double-clicked to run the application. This is be using Windows API or in C#.
I have already used IShellLink Interface but its been hard-coded for icon name. Suppose the user changes desktop icon name then also coding should be able to change its working directory. This can be done if I can check the existence of the icon.
I was using gmtime() on WinCE with Dinkumware libraries. It returned local time instead of UTC. Although I can convert it to UTC by calling GetTimeZoneInformation, still wondering why that is, and if there's any other function can be called?
The compiler outputs an error when i try to allocate a String object as an automatic variable : "C3149: 'System::String' : cannot use this type here without a top-level '^'."
As the problem doesn't appear with my home-made ref class, my actual question is : is there a way to prevent a class from being instantiated as an automatic variable ?