Chilkat HOME ASP Visual Basic VB.NET C# Visual C++ C MFC Delphi FoxPro Java Perl PHP Python Ruby SQL Server VBScript
|
S/MIME Decrypt This Visual Basic sample program shows how to decrypt an x-pkcs7-mime MIME message. The attached content of the unencrypted message (a GIF image in this case) is then saved to a file. ' Loads an encrypted MIME message, unwraps the security envelopes, and determines
' if the decryption was successful.
Private Sub Command1_Click()
Dim mime As New ChilkatMime
' Get a 30-day trial code from http:'www.chilkatsoft.com/register30.asp
mime.UnlockComponent "UnlockCode"
mime.LoadMimeFile "encrypted.txt"
' Determine if this is an encrypted message or not.
If (mime.IsEncrypted() = 1) Then
ListBox1.AddItem "Message is encrypted"
Else
ListBox1.AddItem "Message is not encrypted"
End If
' Unwrap the security.
' The results are stored within the Mime object and can be queried
' afterwards.
' The UnwrapSecurity does all decryption and signature validation,
' regardless of how complex the MIME message may be.
Dim decryptSuccess As Long
decryptSuccess = mime.UnwrapSecurity()
If (decryptSuccess = 1) Then
ListBox1.AddItem "Message has been decrypted"
Else
ListBox1.AddItem "Message not decrypted"
End If
' Save the decrypted MIME message.
mime.SaveMime "decrypted.txt"
' (You can convert any MIME message to XML too.)
mime.SaveXml "decrypted.xml"
' Get the first encrypting certificate.
' In complex cases where the MIME is nested and contains
' other encrypted MIME messages, there will be more than
' one encrypting certificate.
Dim cert As ChilkatCert
Set cert = mime.GetEncryptCert(0)
ListBox1.AddItem "Encrypted By: " + cert.SubjectDN
' This example uses a MIME message that included a GIF attachment.
' Save the GIF to a file.
Dim gifAttachment As ChilkatMime
Set gifAttachment = mime.GetPart(1)
gifAttachment.SaveBody "dude.gif"
End Sub
' Relevant keywords: mime type, mime format, mime tool, mime decoder, mime file, mime decode
' mime file, mime protocol, mime rfc, mime header, email mime, mail mime, mime decoding,
' mime attachment, mime reader, mime download, mime converter, mime content type,
' mime message, mime file type, mime html, mime downloads, mime parser, mime pdf, convert mime
' mime encoding, mime version 1.0, mime pic, mime video, mime software, mime viewer,
'
' content-disposition: attachment; filename="smime.p7m"
' content-transfer-encoding: base64
' content-type: application/x-pkcs7-mime;
' name="smime.p7m"
|
Need a specific example? Send a request to support@chilkatsoft.com
© 2000-2008 Chilkat Software, Inc. All Rights Reserved.