pgp

How do I encrypt a PGP message through java's crypto extension?

若如初见. 提交于 2020-01-05 02:54:12
问题 Currently I'm using bouncy castle's libraries for the actual work and have found an example at sloanseaman.com that (after a little tweaking) works with v1.52. I've also got a working example from developer.com of how to use the JCE interface and can even drop the bcprov in it and use some of it's algorithms. public class CryptoUtil { private static final String ALGORITHM = "IDEA/PGP/NoPadding"; public static void encryptFile(File keyFile, File plainTextFile, File encryptedFile) throws

How to sign public PGP key with Bouncy Castle in Java

泄露秘密 提交于 2020-01-02 09:37:28
问题 I'm writing PGP server to generate keys for users. I want to sign any generated PGP public key with my private key in Java with Bouncy Castle, to make it trusted for my users. I have no problems with generating key pair - it works perfect. I tried to sign by gpg --sign-key command line and it works good. But I can't get the same in Java. I tried many solutions like this: java sign public pgp key with bouncycastle and DirectKeySignature class from BC examples package, but nothing works for my.

Exception on decrypting file using BouncyCastle PGP

廉价感情. 提交于 2019-12-30 07:13:35
问题 I was trying to decrypt this sample file given by the client, using a class called PgpDecrypt. But when the code comes to this line: Stream clear = pbe.GetDataStream(privKey); it returns an error: exception decrypting secret key Here's my decryption code: PgpDecrypt test = new PgpDecrypt(string.Concat(pathh, "TestDecryptionFile"), string.Concat(pathh, "mypgpprivatekey.key"), "mypassphrase", @"d:/test/", string.Concat(pathh, "clientpublickey.key")); FileStream fs = File.Open(string.Concat

PartialInputStream during Bouncycastle PGP decryption

浪子不回头ぞ 提交于 2019-12-29 08:02:11
问题 I am tryng to decrypt a file I just encrypted using bouncycastle, but im getting this exception: Premature end of stream in PartialInputStream I am using the example code from bouncycastle and haven't changed anything. I'm getting this when I use this code for encryption: private static byte[] EncryptFile(byte[] clearData, string fileName, PgpPublicKey encKey, bool withIntegrityCheck) { MemoryStream encOut = new MemoryStream(); try { MemoryStream bOut = new MemoryStream();

FTP Changing PGP File During Transfer in C#

Deadly 提交于 2019-12-24 17:43:36
问题 I have PGP files that I've verified as being valid, but at some point during the FTP upload, they become corrupt. When retrieved, I get an error message stating "Found no PGP information in these file(s)." For what it's worth, the PGP is version 6.5.8, but I think that this is unimportant, as the files seem alright before they're uploaded. My code is as follows for the file transfer, is there a setting or field that I've missed? static void FTPUpload(string file) { FtpWebRequest request =

Flush PGP Encrypted Bouncy Castle OutputStream in Java

天涯浪子 提交于 2019-12-24 10:29:49
问题 I'm working on a proof of concept Java application that reads a series of newline-separated requests from a PGP-encrypted file, processes those requests, and then writes the responses to another PGP-encrypted file, with a flush after each response write. I've successfully integrated Bouncy Castle 1.5 with my application with the exception that I cannot seem to flush the output on command: private ArmoredOutputStream armoredOut = null; private OutputStream compressedOut = null; private

php mcrypt - decrypting and encrypting files?

纵饮孤独 提交于 2019-12-24 08:23:47
问题 I've been looking around for a php class that allows the decryption / encryption of pgp-encrypted csv files. Everything I've found has been primarily geared towards passwords. I'm assuming the principles are essentially the same, but was wondering if someone here can point me in the direction of a class specifically intended to receive files via FTP and decrypt them, as well as encrypt files and FTP them elsewhere? It's my first foray into encryption, so hoping that someone can point me to

.net core PGP Encryption Decryption

廉价感情. 提交于 2019-12-24 07:49:03
问题 Running into error on the void Encryption(). public void Encryption() { #region PGP Encryption PgpEncryptionKeys encryptionKeys = new PgpEncryptionKeys(@"C:\Keys\PGPPublicKey.asc", @"C:\Keys\PGPPrivateKey.asc", "password"); PgpEncrypt encrypter = new PgpEncrypt(encryptionKeys); using (Stream outputStream = File.Create("C:\\Keys\\EncryptData.txt")) { encrypter.EncryptAndSign(outputStream, new FileInfo(@"D:\Keys\PlainText.txt")); } Console.WriteLine("Encryption Done !"); #endregion } I used

Check if GPG/PGP public key is valid

不羁的心 提交于 2019-12-24 07:47:12
问题 Through a web interface I'm trying to check if a given public key is valid or not. The bash command gpg --import key.pub returns import successful/failed based on the given key, but I don't want to use $data = system("/usr/bin/gpg --import $key) for my own security concerns. Is there an alternative? 回答1: Ok, I've done a little debugging and this is what I've found: nginx daemon was running under nginx:nginx , no home dir, nologin shell When I executed sudo -u nginx php -r "echo system("gpg -k

Crypt::OpenPGP Symkey decrypt failed: Invalid secret key ID

[亡魂溺海] 提交于 2019-12-24 03:28:08
问题 I am having a problem where Crypt::OpenPGP is unable to decrypt a message encoded by GPG. It seems that I am not the first to have this problem. But no solution was found on that thread. my $pgp = load_class('Crypt::OpenPGP')->new; $pgp->handle( Data => $encrypted, ) or confess $pgp->errstr; Crypt::OpenPGP prompts correctly for the key passphrase, finding the key successfully, and I'v tested to make sure the passphrase works with GPG. But when attempting to decrypt the message with Crypt: