 |
|
 |
Hi,
I studied ur code for PGP Encryption and Decryption.
It's good. But i am facing problem while doing sign and encrypt.
Can u help me please..?
Input Passed : --homedir "c:\Program Files\GNU\GnuPG" --yes --batch --sign --encrypt --armor --recipient sangar@gmail.com --default-key test@gmail.com --passphrase-fd 0 --no-verbose
Error : Exit code :2 : gpg: no default secret key: No secret key
gpg: [stdin]: sign+encrypt failed: No secret key
|
|
|
|
 |
|
 |
Hi Emmanuel,
Do you have any code sample for file encrypting and de-encrypting ?
If you have please share it with me. My mail kumaran.psd@gmail.com
Thanks & Regards,
kumaran
|
|
|
|
 |
|
 |
I installed the code and just as a test ran an encrypt on the default email message. I get back the following error:
gpg: no default secret key: bad passphrase gpg: [stdin]: sign+encrypt failed: bad passphrase
I can encrypt and decrypt from command line gpg, also with several front ends. I'm wondering why the app can't find the secret key. if I do a gpg -k and list my secret keys, they all show up.
|
|
|
|
 |
|
 |
Hi,
When i try to decrypt .pgp file i got an exception "GnuPGException: usage: gpg [options] --decrypt [filename] at GnuPGWrapper.ExecuteCommand2(String inputText, String& outputText)"
Thsis the code i wrote for decryption.
try
{
GnuPGWrapper gpg = new GnuPGWrapper();
gpg.homedirectory = path;
StreamReader txtReader = new StreamReader(files);
inputText = txtReader.ReadToEnd();
txtReader.Close();
gpg.command = Commands.Decrypt;
gpg.ExecuteCommand(inputText, out outputText);
}
catch (GnuPGException gpge)
{
Response.Write("<p>"+gpge +"</p>");
}
Pls provide sugession
|
|
|
|
 |
|
 |
hi i am using the code. it creates the pubring.gpg and secring.png but
it shows following error.
i am not getting why the secret key is not available.
gpg: keyring `D:/Some R and D/OpenPGP/GnuPGDotNet/GnuPG\secring.gpg' created gpg: keyring `D:/Some R and D/OpenPGP/GnuPGDotNet/GnuPG\pubring.gpg' created gpg: no default secret key: secret key not available gpg: [stdin]: sign+encrypt failed: secret key not available
can you please tell me why this is happening
|
|
|
|
 |
|
 |
I have figured out the problem of large files locking the process and I have also figured out how to encode in UTF8 so that you don't have to use the --armor flag. If you'd like the solution, email me at matthew [-dot-] knapp gmail
|
|
|
|
 |
|
 |
Hi,
I got a quick question. Both our side and reciever side we have been using GPG(along with .net).But now our company(sender side) stopped access to the commandline, so we are not able to use command line based GPG tool for encryption. But the reciever side still using GPG tool to decrypt the messege?
Is it possible to write custom .net code that encrypts the data(without using GPG tool)? so that the recievers can decrypt it using GPG tool. If i follow openpgp standards, can i write .net code that encrypts the data?
Any help would be appreciated
Thanks
|
|
|
|
 |
|
 |
I am currently trying to use the code above to encrypt a string that will then be passed to a 3rd party that uses PGP. I have imported their key and it appears to work on the command line, but when I try to run it from the test web app, I get errors like: "gpgwrap: executing `C:\Projects\web\GnuPGDotNet\gpg2.exe' failed: No such file or directory ". I copied the gpg.exe and gpg2.exe to the GnuPG folder under the web app directory, but that didn't fix the issue. I then tried to map the install directory "C:\Program Files\GNU\GnuPG\" but that gives errors about trying to map to that directory as well. I didn't see where the article explained about the home directory, it's purpose, how to set it up, etc... Does anyone know how to the get the wrapper pointing to the correct gpg.exe for the sample above?
Thanks,
Scott
|
|
|
|
 |
|
 |
I've just tried downloading the zip file GnuPGDotNet_src.zip but all it does is open up another webpage of this article?
Is the zip file still available for download?
|
|
|
|
 |
|
 |
First off - nice job!. Very useful!
In setting up the executable string for pgp.exe, if pgp.exe is accessible from the path variable we can just leave out the home directory setting. I changed the start of ExecuteCommand (around line 434) to the following to accommodate this:
if(string.IsNullOrEmpty(_bindirectory)) {
gpgExecutable = "gpg.exe";
} else {
gpgExecutable = _bindirectory + "\\gpg.exe";
}
|
|
|
|
 |
|
 |
I need help on encrypt and decrypt a file instead of string. Any suggestion will be appreciated.
|
|
|
|
 |
|
 |
You will need to convert the strings to a file. To output to a file use File.WriteAllText(FilePath, stringContent);
|
|
|
|
 |
|
 |
I'm attempting to SignAndEncrypt a string of data. Here is my code setup:
gpg.homedirectory = Server.MapPath(ConfigurationSettings.AppSettings["home"]);
gpg.passphrase = ConfigurationSettings.AppSettings["passphrase"];
gpg.originator = "";
gpg.recipient = ConfigurationSettings.AppSettings["recipient"];
gpg.command = Commands.SignAndEncrypt;
The code calls the wrapper just fine, the wrapper returns a syntax error: usage: gpg [options] --sign --encrypt [filename]
My home directory is on the root of the C drive, no spaces and the recipient does have spaces in their name.
Obviously the command arguments are being built incorrectly as I can reproduce this error if I type in an incorrect series of options in the command prompt.
What would be the best way of diagnosing this problem? Or does anyone have any tips if they've encountered this in the past?
|
|
|
|
 |
|
 |
This error usually means one or more of your parameters are not correct.
Make sure you homedirectory does not end with a "\"
Make sure your recipient is the actual email address
|
|
|
|
 |
|
 |
I quote from the comments of GnuPGWrapper.cs:
"For now, let's assume the gpg.exe program is installed in the homedirectory too"
Really? And for later, let's assume that everyone will get the "System cannot find the file specified" error, pull their hair out for a little while, then realize they have to fix and rebuild the project!
The defaults after installing GnuPG are...
homedirectory = C:\Documents and Settings\[username]\Application Data\GnuPG
bindirectory = C:\Program Files\GNU\GnuPG
...so why assume they'd ever be the same?
(Hmm - this code is from 2002 - maybe defaults used to be the same folder?)
Still, thanks for saving me the time of not having to write this myself!
|
|
|
|
 |
|
 |
I am also hitting this issue! What did you do to resolve this in your application?
Thanks in advance.
|
|
|
|
 |
|
 |
Hi,
We're using gpg4win, that uses a lates version of Gnu.
It uses version 1.4.7, and when I run a sign and encrypt for a file that is over 900kb, is just hangs.
It does work on smaller files, but I need it to work on files as bug as 50mb.
Is there a solution for that?
Thanks
|
|
|
|
 |
|
 |
The process object becomes full and has to buffer out. Which, it cannot because you have not read the data out of the buffer yet(buffered output). You need to create a thread and read and write it your self.
Code---
// in the send string, add your reciepent email address where bhull@racetrac.com is.
static string send = "--homedir \"C:\\gnupg\" --yes --batch --encrypt --armor --recipient bhull@racetrac.com --verbose ";
static ProcessStartInfo startinfo = new ProcessStartInfo(@"C:\gnupg\gpg.exe", send);
static Process procstart;
static string _outputString;
startinfo.WorkingDirectory = GnupgHome;
startinfo.CreateNoWindow = true;
startinfo.UseShellExecute = false;
startinfo.RedirectStandardInput = true;
startinfo.RedirectStandardOutput = true;
startinfo.RedirectStandardError = true;
procstart = Process.Start(startinfo);
procstart.StandardInput.AutoFlush = false;
Thread writer = new Thread(delegate()
{
procstart.StandardInput.WriteLine(_ResultSet);
procstart.StandardInput.Close();
});
writer.Start();
// whatever you want to do here do it. write to file or whatever
writer.join();
|
|
|
|
 |
|
 |
Prior to testing this wrapper, I installed gpg4win and used the WinPT desktop utility to create and import keys. But the wrapper always gave the error “public key not found”.
The cause turned out to be the location of the key files. With a little detective work I discovered that by default, pgp.exe keeps its key files under the user’s profile – in this folder:
C:\Documents and Settings\(user)\Application Data\gnupg
WinPT uses the default files, but GnuPGWrapper overrides this by supplying pgp.exe with a –homedir parameter taken from its “homedirectory” property. That meant that the wrapper was using a different set of key files from the WinPT tool. No wonder the public key was not found.
If you do not supply a home directory, then the wrapper cannot find the pgp.exe program, which it expects to find in the same folder as the keys. (This is not very tidy since one might well want to separate keys from executables.)
In fact, it turns out the wrapper does have a separate variable – bindirectory – for the pgp.exe path, but it is simply copies the homedirectory property into this variable (comment: “For now, let's assume the gpg.exe program is installed in the homedirectory too”). So we can improve things by removing the line below this comment, and adding an explict bindirectory property…
public string bindirectory
{
set
{
_bindirectory = value;
}
}
We can then supply this property with the path to pgp.exe, while leaving homedirectory unset. When called via the wrapper, pgp.exe then works OK using its default keys, as exposed by the WinPT GUI tool.
However, this solution means that the website or application that uses the wrapper must be running under the same user that ran WinPT to create the keys – or have administrator privileges – because the keys are saved in the users profile. Neither is particularly desirable. In fact you might want to run WinPT on your desktop while your application is on a production server.
An alternative solution would be to change the home directory used by WinPT. There is an option for this under Edt -> Preferences -> GPG preferences, but it’s greyed and cannot be changed. Gotya! Or maybe not…
Here’s my solution. Copy the key files from WinPT’s folder (C:\Documents and Settings\(user)\Application Data\gnupg ) to a folder that you know will be accessible to your application, and set homedirectory to point to that. The files to copy are secring.gpg, pubring.gpg and trustdb.gpg.
If you had the same problem, hope you find this useful.
-- modified at 6:56 Monday 30th July, 2007
|
|
|
|
 |
|
 |
Nice one! that has saved me a lot of stress!
|
|
|
|
 |
|
 |
Hi,
I am facing the same problem.
I am trying to solve this issue by generating a new key pair and then copying the pubring.gpg,secring.gpg,trustdb.gpg , gpg.exe into the accessible directory (ex: C:\chary\GnuPGDotNet_src\GnuPGDotNet\GnuPG )
Still i'm getting the same error when i click on encrypt button:
gpg: you@yourcompany.com: skipped: public key not found gpg: [stdin]: encryption failed: public key not found.
Please can some one help me to solve this problem, it's urgent.
chary
|
|
|
|
 |
|
|
 |
|
 |
Hello, I am trying to decrypt a file using this code but I am coming across some errors. I will give you a little information about my project and hopefully you can help me with it.
I am creating a web site in ASP.NET (C#) that will allow a user to upload a file that will then be converted to a dataset. The files that will be uploaded will be encypted. As the file is being converted to a dataset, it will also decrypt it. Here is the code for the decryption:
//The DataSet to Return
DataSet result = new DataSet();
GnuPGWrapper gpg = new GnuPGWrapper("Path");
//Open the file in a stream reader.
StreamReader s = new StreamReader(File);
//Read the rest of the data in the file.
string AllData = s.ReadToEnd();
gpg.passphrase = "passphrase";
gpg.command = Commands.Decrypt;
// Execute GnuPG
string outputText = "";
gpg.ExecuteCommand(AllData, out outputText);
AllData = outputText;
Basically, the text from the file is read into a string and then it should be decrypted. After that, the result should be put back into the string. I have done this successfully with files and the command line, but when I try it here I get the errors: gpg: no valid OpenPGP data found & gpg: decrypt_message failed: eof. Thank you for any help that you can give me.
----------------------------------------------------------------------------------------
I found that the problem with my code was with the file itself. As I read through these forums I found that this will only work with asc ASCII armored files. When I armored the files, everything worked fine.
-- modified at 15:07 Thursday 2nd August, 2007
|
|
|
|
 |
|
 |
Thanks for the reply to your original post. This helped a lot.
|
|
|
|
 |
|
 |
In the code example provided you use a passphrase. I have been asked to be able to encrypt/decrypt based on the use of a public key. How would you use this code to work with the key instead of the passprase?
|
|
|
|
 |