How-to PGP(Pretty Good Privacy) when sending encrypted emails

 

 

Contributed by
Rating: 5 stars5 stars5 stars5 stars5 stars / 2
November 26, 1999
Rate this Article:
MEH MEH++


SEARCH ASP FREE
TOOLS YOU CAN USE

advertisement

How-to send PGP encrypted emails (Pretty Good Privacy)
This is something I hacked a while back for some PGP encrypted emails that I needed to process. Its working nicely for me. I know its ugly but its damn unique! I haven't seen anything out there that does what this code does. I hope you can use it somehow as I'm sure I wasn't the only one looking for an easy way to decrypt/encrypt PGP.

This is the following example uses the DOS based PGP encryption/decryption program
availble from http://www.pgpi.org/ Configure the software with your PGP key by following the directions in the included files.


 
A self made component or a third part component like ASPExec from
http://www.serverobjects.com can be used to execute the PGP decryption
execututable.

An example VB component to do this task would contain the following code in
a Class Module.

Dim sTest, i As Integer
Dim sCommand As String
Dim sPGPTXT As String


Public Property Let Command(temp As Variant)
sCommand = temp
End Property
Public Property Get Command() As Variant
Command = sCommand
End Property
Public Property Let PGPTXT(temp As Variant)
sPGPTXT = temp
End Property
Public Property Get PGPTXT() As Variant
PGPTXT = sPGPTXT
End Property

Public Sub PGPDecrypt()
sTest = Shell(sCommand, vbMinimizedNoFocus)
sTest = ""
i = 0
Do While Not sTest = "Exit"
i = i + 1
If i > 30 Then
sTest = "Exit"
End If
If GetFileAttributes(sPGPTXT) <> -1 Then sTest = "Exit"
Sleep (500)

Loop
End Sub

To call this component from within ASP:

Set oFS = CreateObject("Scripting.FileSystemObject")
Response.Write "Decyrypting"
Set oPGP = Server.CreateObject("NWCRPGP.PGP")
oPGP.Command = "C:\inetpub\wwwroot\pgp\pgp.bat"
oPGP.PGPTXT = "C:\Inetpub\wwwroot\pgp\ASP.TXT"
Response.Write ".."
If oFS.FileExists("C:\Inetpub\wwwroot\pgp\asp.txt") Then
Set oFSTemp = oFS.GetFile("C:\Inetpub\wwwroot\pgp\asp.txt")
oFSTemp.Delete
Set oFSTemp = Nothing
Response.Write "."
End If
If oFS.FileExists("C:\Inetpub\wwwroot\pgp\asp.pgp") Then
Set oFSTemp = oFS.GetFile("C:\Inetpub\wwwroot\pgp\asp.pgp")
oFSTemp.Delete
Set oFSTemp = Nothing
Response.Write "."
End If
Set oFSTemp = oFS.CreateTextFile("C:\Inetpub\wwwroot\pgp\asp.pgp", True)
Response.Write ".."
oFSTemp.Write sTemp
oFSTemp.Close
Set oFSTemp = Nothing
Response.Write ".."
oPGP.PGPDecrypt
Response.Write "...."
Set oFSTemp = oFS.OpenTextFile("C:\Inetpub\wwwroot\pgp\ASP.TXT")
Response.Write oFSTemp.ReadAll
oFSTemp.Close
Set oFSTemp = Nothing
Set oFSTemp = oFS.GetFile("C:\Inetpub\wwwroot\pgp\asp.txt")
oFSTemp.Delete
Set oFSTemp = Nothing
Set oFSTemp = oFS.GetFile("C:\Inetpub\wwwroot\pgp\asp.pgp")
oFSTemp.Delete
Set oFSTemp = Nothing
Set oFS = Nothing
Set oPGP = Nothing

Contained in the pgp.bat file is:
c: CD \inetpub\wwwroot\pgp
pgp -v -o asp.txt -z password asp.pgp

This code is in no way in a condition for production use.

Things to think about:

Decrypting to a file is insecure because your unencrypted message will be
saved, even if temporarily, to the HD which could allow access to it.
Sending the PGP encrypted message directly and receiving to/from the program
would be much more secure. If multiple instances of this ran they would conflict since its using the
same file names.

blog comments powered by Disqus
ASP CODE ARTICLES

- ASP Forms
- ASP: The Beginning
- Getting Remote Files With ASP Continued
- Inbox and Outbox Manipulation in ASP
- Relational DropDownList Using VB.NET
- Ad Tracking URL Hits
- Use ViewState to display one record per page...
- Send Email using ASP.NET formatted in HTML
- ASP File Explorer
- ASP/XML Interview questions by Srivatsan Sri...
- Pressing RETURN won't submit the form
- This shows how you get the TEXT of a combo r...
- Group Data by Adrian Forbes
- Multiple checkbox select sample
- Multiple checkbox select with all values sam...

ASP Web Hosting ASP.Net Web Hosting Windows Web Hosting
 
 
 

ASP Free Forums 
 RSS  Tutorials RSS
 RSS  Forums RSS
 RSS  All Feeds
Site Map 
Request Media Kit
Write For Us Get Paid 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
Privacy Policy 
Support 


© 2003-2012 by Developer Shed. All rights reserved. DS Cluster 7 - Follow our Sitemap
Most Popular Topics
All ASP.Net Tutorials