Click here to Skip to main content
15,885,278 members
Articles / Programming Languages / C#

Gnu Privacy Guard (GPG/PGP) for .NET [v1.0]

Rate me:
Please Sign up or sign in to vote.
4.94/5 (17 votes)
18 Sep 20033 min read 564K   8.7K   91  
This article provides a C# wrapper class (GnuPGWrapper) that will enable use of GnuPG (the OpenPGP Internet encryption standard) within a .NET application.
  • gnupgdotnet_src.zip
    • GnuPGDotNet
      • AssemblyInfo.cs
      • bin
      • CodeCommentReport
        • banner.htm
        • banner.jpg
        • CodeCommentReportError.htm
        • commentreport.css
        • darkcorner.jpg
        • GnuPGDotNet
          • CWP0.HTM
          • CWP10.HTM
          • CWP11.HTM
          • CWP12.HTM
          • CWP13.HTM
          • CWP14.HTM
          • CWP15.HTM
          • CWP16.HTM
          • CWP17.HTM
          • CWP18.HTM
          • CWP19.HTM
          • CWP2.HTM
          • CWP20.HTM
          • CWP21.HTM
          • CWP22.HTM
          • CWP23.HTM
          • CWP24.HTM
          • CWP25.HTM
          • CWP26.HTM
          • CWP27.HTM
          • CWP28.HTM
          • CWP29.HTM
          • CWP3.HTM
          • CWP30.HTM
          • CWP31.HTM
          • CWP32.HTM
          • CWP33.HTM
          • CWP34.HTM
          • CWP35.HTM
          • CWP36.HTM
          • CWP37.HTM
          • CWP38.HTM
          • CWP39.HTM
          • CWP4.HTM
          • CWP40.HTM
          • CWP41.HTM
          • CWP42.HTM
          • CWP43.HTM
          • CWP44.HTM
          • CWP45.HTM
          • CWP46.HTM
          • CWP47.HTM
          • CWP48.HTM
          • CWP49.HTM
          • CWP5.HTM
          • CWP50.HTM
          • CWP51.HTM
          • CWP52.HTM
          • CWP53.HTM
          • CWP54.HTM
          • CWP55.HTM
          • CWP56.HTM
          • CWP57.HTM
          • CWP58.HTM
          • CWP59.HTM
          • CWP6.HTM
          • CWP60.HTM
          • CWP61.HTM
          • CWP62.HTM
          • CWP63.HTM
          • CWP64.HTM
          • CWP65.HTM
          • CWP66.HTM
          • CWP67.HTM
          • CWP68.HTM
          • CWP69.HTM
          • CWP7.HTM
          • CWP70.HTM
          • CWP71.HTM
          • CWP72.HTM
          • CWP73.HTM
          • CWP74.HTM
          • CWP75.HTM
          • CWP76.HTM
          • CWP77.HTM
          • CWP78.HTM
          • CWP79.HTM
          • CWP8.HTM
          • CWP80.HTM
          • CWP81.HTM
          • CWP82.HTM
          • CWP83.HTM
          • CWP84.HTM
          • CWP85.HTM
          • CWP86.HTM
          • CWP87.HTM
          • CWP88.HTM
          • CWP89.HTM
          • CWP9.HTM
          • CWP90.HTM
          • CWP91.HTM
          • CWP92.HTM
          • CWP93.HTM
          • CWP94.HTM
          • CWP95.HTM
          • CWP96.HTM
          • CWP97.HTM
          • CWP98.HTM
          • GnuPGDotNet.HTM
        • gradleft.jpg
        • gradtop.jpg
        • graycorner.jpg
        • minus.jpg
        • plus.jpg
        • Solution_GnuPGDotNet.HTM
        • titletile.jpg
        • vt.js
      • GnuPG.aspx
      • GnuPG.aspx.cs
      • GnuPG.aspx.resx
      • GnuPG
        • gpg.exe
        • pubring.bak
        • pubring.gpg
        • random_seed
        • secring.gpg
        • trustdb.gpg
      • GnuPGDotNet.csproj
      • GnuPGDotNet.jpg
      • GnuPGDotNet.xml
      • GnuPGWrapper.cs
      • gpg.txt
      • ReadMe.html
      • Web.config
  • gpg.zip
<%@ Page language="c#" Codebehind="GnuPG.aspx.cs" AutoEventWireup="false" Inherits="Emmanuel.Cryptography.GnuPG.GnuPG" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<html>
	<head>
		<title>GnuPG</title>
		<meta content="Microsoft Visual Studio 7.0" name=GENERATOR>
		<meta content=C# name=CODE_LANGUAGE>
		<meta content=JavaScript name=vs_defaultClientScript>
		<meta content=http://schemas.microsoft.com/intellisense/ie5 name=vs_targetSchema>
	</head>
	<body>
		<form id=GnuPG method=post runat="server">
			<h2>GnuPGWrapper</h2>
			<p>This page is sample use of GnuPGWrapper, a wrapper class
				for GNU Privacy Guard (GnuPG). It executes the command line program (<code>gpg.exe</code>)
				in
				an different process, redirects standard input (<code>stdin</code>), standard
				output (<code>stdout</code>)
				and standard error (<code>stderr</code>) streams, and monitors the streams to
				fetch the
				results of the encryption/signing operation. </p>
			<p>Please note that you must have INSTALLED GnuPG AND
				generated/imported the appropriate keys before using this class. </p>
			<h2>PGP Form</h2>
			<p>Please fill in the form below a press one of the action buttons to test the 
				GnuPGWrapper.</p>
			<table border=0>
				<tr valign=top>
					<td><asp:label id=Label1 runat="server" font-bold="True">Input Message: </asp:label></td>
					<td><asp:textbox id=MessageTextBox runat="server" textmode="MultiLine" columns="80" rows="5">This is a test message.</asp:textbox></td></tr>
				<tr>
					<td><asp:label id=Label2 runat="server" font-bold="True">From:</asp:label></td>
					<td><asp:textbox id=FromTextBox runat="server" width="243px"></asp:textbox></td></tr>
				<tr>
					<td><asp:label id=Label3 runat="server" font-bold="True">To:</asp:label></td>
					<td><asp:textbox id=ToTextBox runat="server" width="244px"></asp:textbox></td></tr>
				<tr><td colspan=2>&nbsp;</td></tr>
				<tr>
					<td colspan=2>
						<table>
							<tr>
								<td><asp:button id=CryptAndSignButton runat="server" text="Encrypt and Sign"></asp:button></td>
								<td><asp:button id="CryptButton" runat="server" text="Encrypt"></asp:button></td>
								<td><asp:button id="DecryptButton" runat="server" text="Decrypt"></asp:button></td>
								<td><asp:button id="SignButton" runat="server" text="Sign"></asp:button></td>
								<td><asp:button id="VerifyButton" runat="server" text="Verify"></asp:button></td>
							</tr>
						</table>
					</td>
				</tr>
				<tr>
					<td colspan=2><asp:label id=ErrorMessage runat="server" visible="False" forecolor="Red">ERROR!</asp:label></td></tr>
				<tr><td colspan=2>&nbsp;</td></tr>
				<tr>
					<td><asp:label id=Label4 runat="server" font-bold="True">Output Message: </asp:label></td>
					<td><asp:textbox id=OutputTextBox runat="server" visible="False" textmode="MultiLine" columns="80" rows="10"></asp:textbox></td>
				</tr>
				<tr>
					<td><asp:label id="Label5" runat="server" font-bold="True">Exit Code: </asp:label></td>
					<td><asp:label id="ExitCodeLabel" runat="server"></asp:label></td>
				</tr>
			</table>


			<h2>Low-Level Design</h2>

			<p>For more details about the implementation, please refer to the <a href="CodeCommentReport/GnuPGDotNet/GnuPGDotNet.HTM">
					GnuPG .NET Low Level Design</a>.</p>


			<h2>About GnuPG</h2>
			<p>GnuPG stands for GNU Privacy Guard and is GNU's tool for
				secure communication and data storage. It can be used to encrypt data and to
				create digital signatures. It includes an advanced key management facility and
				is compliant with the proposed OpenPGP Internet standard as described in RFC
				2440. As such, GnuPG is a complete and free replacement for PGP. </p>
			<p>This class has been developed and tested with GnuPG
				v1.2.0 (MingW32) </p>
			<p>You can check the <a href="gpg.txt" target="_blank">command line manual page for 
					gpg.exe</a></p>
			<p>
				For more about GNU, please refer to <a href="http://www.gnu.org" target="_blank">http://www.gnu.org</a><br>
				For more about GnuPG, please refer to <a href="http://www.gnupg.org" target="_blank">
					http://www.gnupg.org</a><br>
				For more about OpenPGP (RFC 2440), please refer to <a href="http://www.gnupg.org/rfc2440.html" target="_blank">
					http://www.gnupg.org/rfc2440.html</a><br></p>
		</form>
	</body>
</html>

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


Written By
Web Developer
France France
Fell into computer software at the age of 11, founder of 3 startups, and now manager of an independent software vendor (ISV) labelled proSDK (www.prosdk.com)... And still a freeware writer and technical article author!

Comments and Discussions