Chilkat
HOME
Android™
ASP
Visual Basic
VB.NET
C#
iOS (IPhone)
Objective-C
C++
C
MFC
Delphi
FoxPro
Java
Perl
PHP Extension
PHP ActiveX
Python
PowerShell
Ruby
SQL Server
VBScript
S/MIME DecryptThis 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
mime.UnlockComponent "Anything for 30-day trial"
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
|
© 2000-2012 Chilkat Software, Inc. All Rights Reserved.