本文整理匯總了Java中org.bouncycastle.openpgp.PGPUtil.setDefaultProvider方法的典型用法代碼示例。如果您正苦於以下問題:Java PGPUtil.setDefaultProvider方法的具體用法?Java PGPUtil.setDefaultProvider怎麽用?Java PGPUtil.setDefaultProvider使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.bouncycastle.openpgp.PGPUtil
的用法示例。
在下文中一共展示了PGPUtil.setDefaultProvider方法的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: performTest
import org.bouncycastle.openpgp.PGPUtil; //導入方法依賴的package包/類
public void performTest()
throws Exception
{
PGPUtil.setDefaultProvider("BC");
//
// Read the public key
//
PGPPublicKeyRing pubKeyRing = new PGPPublicKeyRing(testPubKey, new JcaKeyFingerprintCalculator());
doBasicKeyRingCheck(pubKeyRing);
//
// Read the private key
//
PGPSecretKeyRing secretKeyRing = new PGPSecretKeyRing(testPrivKey, new JcaKeyFingerprintCalculator());
testDecrypt(secretKeyRing);
encryptDecryptTest();
generate();
}
示例2: performTest
import org.bouncycastle.openpgp.PGPUtil; //導入方法依賴的package包/類
public void performTest()
throws Exception
{
PGPUtil.setDefaultProvider("BC");
//
// Read the public key
//
PGPPublicKeyRing pubKeyRing = new PGPPublicKeyRing(testPubKey, new JcaKeyFingerprintCalculator());
doBasicKeyRingCheck(pubKeyRing);
//
// Read the private key
//
PGPSecretKeyRing secretKeyRing = new PGPSecretKeyRing(testPrivKey, new JcaKeyFingerprintCalculator());
generate();
}
示例3: performTest
import org.bouncycastle.openpgp.PGPUtil; //導入方法依賴的package包/類
public void performTest()
throws Exception
{
PGPUtil.setDefaultProvider("BC");
//
// Read the public key
//
PGPPublicKeyRing pubKeyRing = new PGPPublicKeyRing(testPubKey, new JcaKeyFingerprintCalculator());
for (Iterator it = pubKeyRing.getPublicKey().getSignatures(); it.hasNext();)
{
PGPSignature certification = (PGPSignature)it.next();
certification.init(new JcaPGPContentVerifierBuilderProvider().setProvider("BC"), pubKeyRing.getPublicKey());
if (!certification.verifyCertification((String)pubKeyRing.getPublicKey().getUserIDs().next(), pubKeyRing.getPublicKey()))
{
fail("self certification does not verify");
}
}
//
// Read the private key
//
PGPSecretKeyRing secretKeyRing = new PGPSecretKeyRing(testPrivKey, new JcaKeyFingerprintCalculator());
generateAndSign();
}
示例4: main
import org.bouncycastle.openpgp.PGPUtil; //導入方法依賴的package包/類
public static void main(String[] args)
throws Exception
{
Security.addProvider(new BouncyCastleProvider());
PGPUtil.setDefaultProvider("BC");
//
// Read the public key rings
//
PGPPublicKeyRingCollection pubRings = new PGPPublicKeyRingCollection(
PGPUtil.getDecoderStream(new FileInputStream(args[0])));
Iterator rIt = pubRings.getKeyRings();
while (rIt.hasNext())
{
PGPPublicKeyRing pgpPub = (PGPPublicKeyRing)rIt.next();
try
{
pgpPub.getPublicKey();
}
catch (Exception e)
{
e.printStackTrace();
continue;
}
Iterator it = pgpPub.getPublicKeys();
boolean first = true;
while (it.hasNext())
{
PGPPublicKey pgpKey = (PGPPublicKey)it.next();
if (first)
{
System.out.println("Key ID: " + Long.toHexString(pgpKey.getKeyID()));
first = false;
}
else
{
System.out.println("Key ID: " + Long.toHexString(pgpKey.getKeyID()) + " (subkey)");
}
System.out.println(" Algorithm: " + getAlgorithm(pgpKey.getAlgorithm()));
System.out.println(" Fingerprint: " + new String(Hex.encode(pgpKey.getFingerprint())));
}
}
}