Question:
I've the s/mime encrypted text files.I need to decrypt the given text files and show the orignial content to user. The content look like below. Needs help.
Message-ID: 20631685.1349796827856.abc@def.com Date: Sat, 9 Jan 2013 10:33:47 -0500 (CDT) To: test@abc.com From: test@abc.com Subject: testing MIME-Version: 1.0 Content-Disposition: attachment; filename="smime.p7m" Content-Type: application/x-pkcs7-mime; name="smime.p7m" Content-Transfer-Encoding: base64 Content-Length: 19217
MIAGCSqGSIb3DQEHA6CAMIACAQAxggRRMIIBigIBADCB8jCB3TELMAkGA1UEBhMCVVMxFzAVBgNV BAoTDlZlcmlTaWduLCBJbmMuMR8wHQYDVQQLExZWZXJpU2lnbiBUcnVzdCBOZXR3b3JrMTswOQYD VQQLEzJUZXJtcyBvZiB1c2UgYXQgaHR0cHM6Ly93d3cudmVyaXNpZ24uY29tL3JwYSAoYykwOTEe MBwGA1UECxMVUGVyc29uYSBOb3QgVmFsaWRhdGVkMTcwNQYDVQQDEy5WZXJpU2lnbiBDbGFzcyAx
bool success = false;
string filename = @"c:\temp\ecrypted.txt";
Chilkat.Mime mime = new Chilkat.Mime();
string license = "30 Days Trial Key";
success = mime.UnlockComponent(license);
success = mime.LoadMimeFile(filename);
success = mime.Decrypt2(objCert, objPrivateKey);
string result = mime.GetMime();
using (StreamWriter writer = new StreamWriter(@"c:\temp\decrypted.txt"))
{
writer.Write(result);
}
o/p : decrypted.txt:
Message-ID: 20631685.1349796827856.abc@def.com Date: Sat, 9 Jan 2013 10:33:47 -0500 (CDT) To: test@abc.com From: test@abc.com Subject: testing MIME-Version: 1.0 Content-Disposition: attachment; filename="smime.p7m" Content-Type: application/x-pkcs7-mime; name="smime.p7m" Content-Transfer-Encoding: base64 Content-Length: 19217
***Decrypted Content stars here**
or we can use mailman for decrypt the test file,
MailMan mailman = new MailMan();
success = mailman.UnlockComponent("30daytrial");
mailman.SetDecryptCert2(objCert, objPrivateKey);
Email mail = objMailman.LoadEml(filename);
string resultText = mail.GetMime();