标签: openpgp

openpgp 和 golang

我对文档有一些问题。

这是我的程序:

package main

import (
    "bytes"
    "code.google.com/p/go.crypto/openpgp"
    "encoding/base64"
    "fmt"
)

func main() {

    var entity *openpgp.Entity
    entity, err := openpgp.NewEntity("bussiere", "test", "bussiere@gmail.com", nil)
    if err != nil {

    }

    var (
        buffer bytes.Buffer
    )

    entity.SerializePrivate(&buffer, nil)
    data := base64.StdEncoding.EncodeToString([]byte(buffer.String()))

    fmt.Printf("%q\n", data)

    entity.Serialize(&buffer)
    data2 := base64.StdEncoding.EncodeToString([]byte(buffer.String()))

    fmt.Printf("%q\n", data2)

    entity.PrivateKey.Serialize(&buffer)
    data3 := base64.StdEncoding.EncodeToString([]byte(buffer.String()))

    fmt.Printf("%q\n", data3)

    entity.PrimaryKey.Serialize(&buffer)
    data4 := base64.StdEncoding.EncodeToString([]byte(buffer.String()))

    fmt.Printf("%q\n", data4)

    //fmt.Printf(buffer.String())

}
Run Code Online (Sandbox Code Playgroud)

以下是数据:

https://gist.github.com/bussiere/5159890
Run Code Online (Sandbox Code Playgroud)

这是要点上的代码:

https://gist.github.com/bussiere/5159897
Run Code Online (Sandbox Code Playgroud)

什么是公钥?

以及如何使用它?

以及如何制作更大的钥匙?

pgp go openpgp

2
推荐指数
1
解决办法
1690
查看次数

如何用Java生成PGP证书

我目前正在使用Bouncy Castle库(1.45)来生成X509证书(即X509V1CertificateGenerator),现在我需要能够在密钥库中创建和导入/导出PGP证书.但是,我没有看到任何支持在他们的"openpgp"包中生成PGP证书.

我所看到的只是PGPKeyRingGenerator,PGPSignatureGenerator.我愿意使用另一个Java库.非常感谢你.

java bouncycastle pgp openpgp x509certificate

2
推荐指数
1
解决办法
2468
查看次数

openpgp golang gpg库的问题

所以我对golang很新,我很难找到一个工作的例子,用openpgp加密一些文本并再次解密.

以下是我到目前为止:(https://gist.github.com/93750a142d3de4e8fdd2.git)

package main

import (
    "log"
    "bytes"
    "code.google.com/p/go.crypto/openpgp"
    "encoding/base64"
    "io/ioutil"
    "os"
)

// create gpg keys with
// $ gpg --gen-key
// ensure you correct paths and passphrase

const mysecretstring = "this is so very secret!"
const secretKeyring = "/Users/stuart-warren/.gnupg/secring.gpg"
const publicKeyring = "/Users/stuart-warren/.gnupg/pubring.gpg"
const passphrase = "1234"

func main() {
    log.Printf("Secret: ", mysecretstring)
    log.Printf("Secret Keyring: ", secretKeyring)
    log.Printf("Public Keyring: ", publicKeyring)
    log.Printf("Passphrase: ", passphrase)

    // Read in public key
    keyringFileBuffer, _ := os.Open(publicKeyring)
    defer keyringFileBuffer.Close()
    entitylist, …
Run Code Online (Sandbox Code Playgroud)

encryption gnupg go openpgp public-key-encryption

2
推荐指数
1
解决办法
2624
查看次数

在命令行上使用 GnuPG 加密文件永远挂起

我想用 GnuPG 加密一个文件

    gpg2 --homedir=~/.gnupg --always-trust=true --recipient="BlahBlah" --encrypt=/path/to/file --output=/path/to/output_file
Run Code Online (Sandbox Code Playgroud)

然而,这个命令似乎永远挂起并且永远不会返回。有趣的是,在我中断进程后,确实/path/to/output_file创建了 ,但是写入那里的字节比原始有效负载大得多(例如,我/path/to/file只有 5 个字节,但结果写入了近 200 个字节/path/to/output_file)。

一定有什么问题,但我真的想不通是什么。

我已经提前导入了BlahBlahby的密钥gpg --import key.asc。GnuPG 1 和 GnuPG 2 都会发生这种情况。

encryption gnupg pgp openpgp

2
推荐指数
1
解决办法
3320
查看次数

PGP 密钥服务器和 Bouncy Castle OpenPGP API Java

是否有可能(以及如何)与 PGP 密钥服务器通信,例如https://pgp.mit.eduhttp://keyserver.pgp.com或私钥服务器:上传密钥、搜索密钥、下载钥匙等 - 在 Java 上使用 Bouncy Castle OpenPGP API?

Java 上是否有任何开源的 PGP 密钥服务器实现?

java bouncycastle gnupg pgp openpgp

2
推荐指数
1
解决办法
744
查看次数

Java:使用 Bouncy Castle 的 PGP 加密

我正在尝试使用 PGP 实现加密,并且我的加密方法成功地加密了输入字符串,但是当我尝试对其进行解密以验证加密是否正确完成时,该字符串没有被解密。

我尝试了两种方法:

1st approach uses FileOutputStream to write encrypted string & 2nd approach uses ByteArrayOutputStream. FileOutputStream creates a file and I am able to decrypt it using Kleopatra. However my requirement is to just get an encrypted string (not written in a file). So when I try to decrypt the encrypted string (received after using ByteArrayOutputStream) its not working. I tried copying the string and decrypting it through tools>>clipboard in Kleopatra, but the decrypt/verify option is …

java encryption bouncycastle openpgp

2
推荐指数
1
解决办法
6824
查看次数

如何替换Linq Cast表达式?

问题:我从这里获得了一些pgp加密代码:http: //blogs.microsoft.co.il/blogs/kim/archive/2009/01/23/pgp-zip-encrypted-files-with-c.aspx

它有以下方法,使用一些LINQ.我仍然在使用.NET 2.0并且无法切换到更高版本,但......

如何用普通代码替换此表达式?我真的不懂Linq,我猜它会做一些排序吗?

 private PgpSecretKey GetFirstSecretKey(PgpSecretKeyRingBundle secretKeyRingBundle)
        {
            foreach (PgpSecretKeyRing kRing in secretKeyRingBundle.GetKeyRings())
            {
                PgpSecretKey key = kRing.GetSecretKeys()
                    .Cast<PgpSecretKey>()
                    .Where(k => k.IsSigningKey)
                    .FirstOrDefault();
                if (key != null)
                    return key;
            }
            return null;
        }
Run Code Online (Sandbox Code Playgroud)

.net c# linq pgp openpgp

1
推荐指数
1
解决办法
284
查看次数

如何判断 OpenPGP 加密是对称还是非对称?

有没有办法判断通过 GNU Privacy Guard 加密的内容是对称的还是非对称的(无需解密或已经知道开始)?如何?

无论如何(对于那些想知道我在做什么的人),我使用 Python 3.x 编写了一个基于 GUI 的 IDE,可以打开对称加密的文件(也可以保存它们)。它可以打开非对称加密的文件(输入密码以使用您的密钥而不是密码来解密对称加密的文件)。但是,它不知道它们是不对称的,并且如果保存,则会用对称加密的文件覆盖它们。如果能够以不对称的方式保存它们,那就太好了。我的编辑器使用gpgLinux 上的命令行程序(没有gpg库或类似的东西)。

我可以在非对称加密的密码提示上有一个复选框,但我不想这样做,所以它必须是用户手动操作的。

对于我自己的个人文件,我可以在保存的文件中添加某种标记来区分,但我希望它能够正确打开它们,即使它们不是在我的 IDE 中创建的。

我知道有一个标题相似的问题,但正文中提出的问题根本不同。

encryption gnupg openpgp python-3.x

1
推荐指数
1
解决办法
1852
查看次数

删除“BEGIN”和“END PGP MESSAGE”字符串会使解密中断

我正在使用以下命令使用 GnuPG 加密纯文本:

gpg2.exe --encrypt --armor --recipient <<recipient>>
Run Code Online (Sandbox Code Playgroud)

这将输出返回为

-----BEGIN PGP MESSAGE-----Version: GnuPG v2hQEMAzFXJ94q1Nm8AQf/Tld0/3dAvgFKPQVBS8bmbXChXeApeReo1ydNS+OXeIYwZOwld8ykP3G5EzfxNin2CRpcdgGu7mUFQfd5H80TVjVsCGrlT+0fhOsUrh3P3mTxl9CExVtz0R2e8Ot5aibAMXA5EsAZSJJF0IULCCWSeD49FhwTYWkOZVKrTJ6SKyRU65MLT2sEKb4Bh7EddiK2hmJ4vQx1uJYbeR+rdbyEBKPRHXy1WfJO24KBqSL3e7X1eFNfBiwUU7T1pabLtuCffdNDdBA1EOAPfUgFJi0NPaL0j5eJq2Lqpmoe62EPROIfvEr5b533d4FSHRCiH3Y8Hvea/TXaYYj5i9Ccj3K5VtJlAepwPKN16nT2BLwMPwgMPRdSMfd07g0IxPOq2WarAbgapJkJHyDetE7qWThgmMqxaiCi9mdtdkmAICZnVkDuA+f85kHpESS/WIf0o6v5l69JsHUkgfVJpsJ1FccY6gatfnML38c==DbOJ-----END PGP MESSAGE-----
Run Code Online (Sandbox Code Playgroud)

现在,当我解密同一个字符串时,它正在解密,但是当我从这个字符串中删除-----BEGIN PGP MESSAGE-----Version: GnuPG v2和时-----END PGP MESSAGE-----,返回以下错误消息:

gpg: no valid OpenPGP data found.
gpg: decrypt_message failed: Unknown system error
Run Code Online (Sandbox Code Playgroud)

有任何想法吗?

c# gnupg openpgp

1
推荐指数
1
解决办法
3883
查看次数

Find in Path 文本框预填充随机字符串

Android Studio / IntelliJ Find in Files 预填充随机字符串 / 哈希 / uuid / guid / 指纹。我如何阻止这种情况发生? 预填的废话

macos keyboard-shortcuts intellij-idea openpgp android-studio

1
推荐指数
1
解决办法
143
查看次数

可以从PGP PRIVATE KEY生成公钥吗?

我正在用openpgp使用公钥创建我的java产品的许可证.产品随附私钥以读取许可证文件.这是正确的方法吗?私钥可以用于生成公钥吗?

谢谢

java openpgp

0
推荐指数
1
解决办法
271
查看次数

使用Bouncy Castle(C#)生成PGP密钥环会导致密钥ID为FFFFFFFF

我尝试使用Bouncy Castle for C#生成一个RSA密钥对.我按照http://bouncycastle-pgp-cookbook.blogspot.de/2013_01_01_archive.html上的 Java教程进行操作,并创建主密钥和签名密钥.我的代码看起来像

IAsymmetricCipherKeyPairGenerator generator
    = GeneratorUtilities.GetKeyPairGenerator("RSA");
generator.Init(keyRingParams.RsaParams);

/* Create the master (signing-only) key. */
PgpKeyPair masterKeyPair = new PgpKeyPair(
    PublicKeyAlgorithmTag.RsaSign,
    generator.GenerateKeyPair(),
    DateTime.UtcNow);
Debug.WriteLine("Generated master key with ID "
    + masterKeyPair.KeyId.ToString("X"));

PgpSignatureSubpacketGenerator masterSubpckGen
    = new PgpSignatureSubpacketGenerator();
masterSubpckGen.SetKeyFlags(false, PgpKeyFlags.CanSign
    | PgpKeyFlags.CanCertify);
masterSubpckGen.SetPreferredSymmetricAlgorithms(false,
    (from a in keyRingParams.SymmetricAlgorithms
        where a.IsSelected
        select (int) a.Value).ToArray());
masterSubpckGen.SetPreferredHashAlgorithms(false,
    (from a in keyRingParams.HashAlgorithms
        where a.IsSelected
        select (int) a.Value).ToArray());

/* Create a signing and encryption key for daily use. */
PgpKeyPair encKeyPair = new PgpKeyPair(
    PublicKeyAlgorithmTag.RsaGeneral, …
Run Code Online (Sandbox Code Playgroud)

c# bouncycastle openpgp

0
推荐指数
1
解决办法
9678
查看次数