2013-03-14 57 views
2

我需要爲unix機器創建一個公鑰來向我發送加密數據。用電子郵件創建bouncycastle PGPSecretKey

我所做的是使用以下構造函數來創建PGPSecreyKey。

PGPSecretKey secretKey = new PGPSecretKey(PGPSignature.DEFAULT_CERTIFICATION, PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(), 
      "Test [email protected]", PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC"); 

當用Kleopatra打開(檢查我的證書)時,我看到名稱:「Test [email protected]」和Email:「」。

如何使用名稱和電子郵件創建PGP密鑰(並在可能的情況下發表評論)。

在此先感謝!

回答

1

要添加電子郵件地址,您必須將電子郵件連接到用戶ID。 像

PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(), 
      "Hans Mueller <[email protected]>", PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC"); 
-1

要解決這個問題,你必須添加的姓名和電子郵件

PGPPublicKey.RSA_GENERAL, publicKey, privateKey, new Date(), 
      "Hans Mueller \n <[email protected]>", PGPEncryptedData.CAST5, passPhrase, null, null, new SecureRandom(), "BC"); 
之間\ n換行