|
Hello.
I made a simple C++ program in Visual Studio 6 (MFC SDI). It sends a mail message using MAPI (mapi32.dll) and it works great and is easy to use.
But I don't undestannd how to attach a digital signature (stored in local certificates) to my message.
Outlook is set to add digital signature to all new messages but it ignores messages created by my C++ program.
Please help.
Best regards, Alex.
modified 7-Oct-13 10:31am.
|
|
|
|
|
Digital signature prevents email content is faked or changed in transport level. Encrypting email protects email content from exposure to inappropriate recipients. Both digital signature and email encrypting depend on digital certificate.
If you have an email digital signature certificate installed on your machine, you can find it in Control Panel-interner option-content-Certificates-Personal
Then you can use your email certificate to sign the email by the following code. If you don't have a certificate for your email address, you MUST get a digital certificate for personal email protection from third-party certificate authorities such as www.verisign.com.
#include "stdafx.h"
#include "easendmailobj.tlh"
using namespace EASendMailObjLib;
int _tmain(int argc, _TCHAR* argv[])
{
::CoInitialize( NULL );
IMailPtr oSmtp = NULL;
oSmtp.CreateInstance( "EASendMailObj.Mail");
oSmtp->LicenseCode = _T("TryIt");
// Set your sender email address
oSmtp->FromAddr = _T("test@emailarchitect.net");
// Add recipient email address
oSmtp->AddRecipientEx( _T("support@emailarchitect.net"), 0 );
// Set email subject
oSmtp->Subject = _T("email from Visual C++ with digital signature(S/MIME)");
// Set email body
oSmtp->BodyText = _T("this is a test email sent from Visual C++ with digital signature");
// Your SMTP server address
oSmtp->ServerAddr = _T("smtp.emailarchitect.net");
// User and password for ESMTP authentication, if your server doesn't
// require User authentication, please remove the following codes.
oSmtp->UserName = _T("test@emailarchitect.net");
oSmtp->Password = _T("testpassword");
// If your SMTP server requires SSL connection, please add this line
//oSmtp->SSL_init();
// Add signer digital signature
if( oSmtp->SignerCert->FindSubject(_T("test@emailarchitect.net"),
CERT_SYSTEM_STORE_CURRENT_USER , _T("my")) == VARIANT_FALSE )
{
_tprintf(_T("Error with signer certificate; %s\r\n"),
(const TCHAR*)oSmtp->SignerCert->GetLastError());
return 0;
}
if( oSmtp->SignerCert->HasPrivateKey == VARIANT_FALSE )
{
_tprintf(_T("certificate does not have a private key, it can not sign email.\r\n" ));
return 0;
}
_tprintf(_T("Start to send email ...\r\n" ));
if( oSmtp->SendMail() == 0 )
{
_tprintf( _T("email was sent successfully!\r\n"));
}
else
{
_tprintf( _T("failed to send email with the following error: %s\r\n"),
(const TCHAR*)oSmtp->GetLastErrDescription());
}
if( oSmtp != NULL )
oSmtp.Release();
return 0;
}
|
|
|
|
|
Hi there.
I am looking for a simple, basic, preferable a C way of parsing multipart/form-data POST request from a client browser. So far I have a really simple web server, which reads web browser requests in a loop and prints them to to command prompt window:
do
{
len = recv(..., input_buf, ...);
}
while (!strstr(input_buf, "\r\n\r\n") && len > 0);
char * pch = nullptr, *context = nullptr;
pch = strtok_s(input_buf, "\r\n", &context);
while (pch != nullptr)
{
::puts(pch);
pch = strtok_s (nullptr, "\r\n", &context);
}
When this web server starts, it just shows the following web form to the web browser:
<form type=multipart/form-data method=post action=submit><input type=file multiple required /><input type=submit /></form>
So far so good, ok, I connect to my server with firefox, select some test text file, which is a really small one - just a couple of bytes and hit an html form submit button. Server reads request and I have the following output in command prompt window:
POST /submit HTTP/1.1
Host: localhost:6666
User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:24.0) Gecko/20100101 Firefox/
24.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: http://localhost:6666/
Connection: keep-alive
Content-Type: application/x-www-form-urlencoded
Content-Length: 0
But the question is, how do I get file data? I was reading tons of online docs, when it says something about boundary strings - I have no idea what are boundary strings. I am just trying to figure out how to grab raw bytes file data. I cannot use any 3rd party libraries. And what concerns me, is that Content-Length is zero - seems like file was not transferred at all
Can anyone help me with this?
Thanks in advance
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
Figured it out - there is an error in my html form, it should be enctype , not type . Now I have a file content.
011011010110000101100011011010000110100101101110
0110010101110011
|
|
|
|
|
I would like to use a "Big Number" package for my application which I am writing on Windows using Visual Studio and C++. Therefore, I thought I would use GMP. However, I get the impression that compiling it under Windows is going to be a big job. Therefore, I am wondering if it is worth doing.
Could somebody suggest a different package that is more geared towards the windows environment?
Thanks
Bob
|
|
|
|
|
Depending on what you need libtommath[^] may do the job for you. It's a C library I've used in several projects along with libtomcrypt. These are in ansi C. Their source is clean. Public domain. Check out the libs of this guy, they are excellent.
The LICENSE file:
LibTomMath is hereby released into the Public Domain.
-- Tom St Denis
|
|
|
|
|
-1
down vote
favorite I have this program that needs to handle large numbers to factorize a number into primes.. Just like the RSA factorization challenge.
I got this list in a txt file with prime numbers. this is the piece of code I use to make that list:
int export_list (int lim = 50)
{
int last_in_txt = 0;
{
ifstream infile ("Primes.txt");
int k;
while(infile >> k)
{ last_in_txt = k; }
}
// Now last_in_txt is assigned properly, and Primes.txt is closed
cout << "\nLast number in \"Primes.txt\": " << last_in_txt << endl << endl;
cout << "Press <enter> to start appending primes... ";
cin.get();
cout << "\nAppend started:\n";
last_in_txt++;
ofstream file ("Primes.txt" , ios::app);
int x, counter;
if (file.is_open()) // if it opens correctly
{
for (x = last_in_txt , counter = 0 ; counter < lim ; x++ , counter++)
{
if (check_prime (x)) // returns 1 when x is prime, returns 0 when not
{
cout << "Appending " << x << "\t\t" << "Estimated time remaining: " << (lim - counter) / 1000 <
|
|
|
|
|
A software is executing some websites links (URLs) internally, Can I get to know which links are thses?
|
|
|
|
|
No. Unless the application offers some way of making them public.
Veni, vidi, abiit domum
|
|
|
|
|
john5632 wrote: Can I get to know which links are thses?
Look at the code.
Put a interceptor in place which catches http requests.
Both of those of course require that you have internal access. However the above applies if you are executing something on your machine rather than a remote server.
|
|
|
|
|
Why not use a packet sniffer?
Wireshark[^] would do the trick... it's a very mature product that's been around for ages (used to be called Ethereal) and is very reliable and used by many.
|
|
|
|
|
Hey there,
I have a C++ WIN32 DLL that acts as a server for a UI. Now i want to capture all keyboard inputs in the PC on the WIN32 dll, whenever the UI has active focus. If the user is typing something into another app, i don't care.
The trick is that, the keyboard can be both a software keyboard or a hardware keyboard. I want to be able to capture every keyboard input from the user on the PC in which the UI and DLL is running.
I would ideally like to get a little deeper on the Windows operating system level to do this. Rather than using WM_CHAR or something like that.
Is this possible to do? How can i implement this?
Any sample code will help.
Thanks in advance.
|
|
|
|
|
This[^] or this[^] could be a start, I'm sure there are plenty of others out there.
|
|
|
|
|
First I tried using kbhit() and getch() to recognize and capture the users input. I call the code below every frame (I tested in BL:R) but nothing happens.
PHP Code
if(kbhit())content += getch();
|
|
|
|
|
|
I'm working on Audio Capture of my system and I did it using loopback capture method to record my audio. I recorded the file and its fine in non compressed form.
I want to make it in small size or compressed form.
But from last two days I'm searching for a way to encode it into .aac format using ffmpeg or something else.
Do anyone having any idea for this?
Please share your opinions.
Thanks!
|
|
|
|
|
Are you looking to do these conversions within your program? If so, take a look at some of the responses in this [^] thread.
|
|
|
|
|
I've gone through this but not getting the exact info what I want to do.
Any other suggestion.
|
|
|
|
|
CodingHell wrote: what I want to do
Which is?
|
|
|
|
|
Semi-programming rant
Am I the only one who gets caught using someone else program only to find out it is limited to “click this and click that”?
After embarking on using FFT to analyze audio signals and getting strange results I found out that the basic “recorder” application I am using does not truly records the audio as I expected.
The data stream is padded with several 0 before the real data is recoded.
OK , I can figure this out , but I need to go to very root of this sample application.
For example – it uses PCMFORMAT and than builds WAVE “PCM”structures.
I cannot find anywhere where the PCMFORMAT is actually defined.
I don't need an explanation what “PCM” is / does, just like to know where this PCMFORMAT structure is defined. That's all.
Cheers Vaclav
|
|
|
|
|
PCMFORMAT is not in the Visual Studio headers.
Where does it come from ? what source file uses it ? I assume that if it compiles, then it should be defined somewhere ?
Are you certain it is not PCMWAVEFORMAT ?
I'd rather be phishing!
|
|
|
|
|
This seems pointless - you are just confirming what I already know.
And what makes you think I am not certain?
Sorry, not in the mood for exchanging stuff like this here.
Just for kicks - it is used in CRecorder class which does not have any info where it came from.
The class itself has #include <mmsystem.h> and
#pragma comment(lib,"winmm.lib").
Have a nice day anyway.
Grumpy old man Vaclav
|
|
|
|
|
When doing customer support, one always ask the obvious questions !
I'd rather be phishing!
|
|
|
|
|
And the obvious answer in my case - typedef struct _PCMFORMAT.... defining four basic PCM parameters later copied to PCMWAVAE....
Sorry to be so grumpy.
Vaclav
|
|
|
|
|
I don't know where the definition of PCMFORMAT is... but I can tell you what PCM is...
PCM stands for Pulse Code Modulation and is essentially a three step process for a encoding a real life signal into a digital form that can be used within a computer.
1. Sample (sample the analog signal)
2. Quantize (quantize to a level that can be encoded given the number of states you have available)
3. Encode (encode the quantized value into an appropriate numbering scheme)
It's really that simple to understand. Differences come in the variations available for these three variables. For example, your sampling rate could be 33KHz, or 48KHz, or something else. It depends on available hardware and what you expect to the highest frequency of interest. The quantization states are dependent on how many bits you are using and how many distinct possible values they can represent. Obviously, more states equals more values and therefore more fidelity in representing a signal (wider dynamic range). Third, the encoding can be an unsigned integer, a signed integer (common ones)... or can really have any arbitrary encoding a designer wishes.
|
|
|
|