當前位置: 首頁>>代碼示例>>Java>>正文


Java PGPUtil.setDefaultProvider方法代碼示例

本文整理匯總了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();
}
 
開發者ID:NoYouShutup,項目名稱:CryptMeme,代碼行數:24,代碼來源:PGPECDHTest.java

示例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();
}
 
開發者ID:credentials,項目名稱:irma_future_id,代碼行數:20,代碼來源:PGPECDHTest.java

示例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();
}
 
開發者ID:NoYouShutup,項目名稱:CryptMeme,代碼行數:31,代碼來源:PGPECDSATest.java

示例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())));
        }
    }
}
 
開發者ID:NoYouShutup,項目名稱:CryptMeme,代碼行數:50,代碼來源:PubringDump.java


注:本文中的org.bouncycastle.openpgp.PGPUtil.setDefaultProvider方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。