亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關(guān)于我們
? 蟲蟲下載站

?? hybrid.java

?? 一個java開發(fā)的非常全面的關(guān)于證書發(fā)放
?? JAVA
?? 第 1 頁 / 共 5 頁
字號:
            ioe.printStackTrace();
            throw new CryptoException(ioe.getMessage());
        } finally {
            if (dao != null) {
                // close outputstream
                try {
                    dao.close();
                } catch (IOException e) {
                    ;
                }
            }
        }
    }

    /**
     * Encrypt and sign a file
     *
     * @param file file to encrypt
     * @param newfile encrypted file
     * @param receiverKey the public key of the receiver
     * @param signingKey the private key of the signer
     * @param cert the signer's certificate
     * @param signame the signature's algorithm (e.g."MD5withRSA")
     * @param algorithm encryption algorithm (e.g. "Rijndael")
     * @param seed for SecureRandom (optional)
     * @param strength the keysize in bits (e.g. 128)
     * @param mode encryption mode (e.g. "CBC")
     * @param padding padding scheme (e.g."PKCS7Padding")
     * @throws CryptoException encryption errors
     * @throws IOException I/O errors
     */
    public static void encryptFileAndSign(String file
                                          , String newfile
                                          , PublicKey receiverKey
                                          , PrivateKey signingKey
                                          , X509Certificate cert
                                          , String signame
                                          , String algorithm
                                          , byte[] seed
                                          , int strength
                                          , String mode
                                          , String padding)
            throws CryptoException, IOException {

        FileInputStream fis = null;
        FileOutputStream fos = null;
        DataOutputStream dao = null;

        try {
            fis = new FileInputStream(file);

            fos = new FileOutputStream(newfile);
            dao = new DataOutputStream(fos);

            // encrypt file
            encryptAndSign(fis, dao, receiverKey, signingKey, cert, signame, algorithm, seed, strength, mode, padding, BUFFERSIZE_FILE);

        } catch (IOException ioe) {
            ioe.printStackTrace();
            throw new IOException(ioe.getMessage());
        } finally {
            if (dao != null) {
                // close outputstream
                try {
                    dao.close();
                } catch (IOException e) {
                    ;
                }
            }
            if (fis != null) {
                // close outputstream
                try {
                    fis.close();
                } catch (IOException e) {
                    ;
                }
            }
        }
    }

    /**
     * Encrypt and sign any inputstream
     *
     * @param is inputstream to encrypt
     * @param daos outputstream to store the encrypted & signed data
     * @param receiverKey the public key of the receiver
     * @param signingKey the private key of the signer
     * @param cert the signer's certificate
     * @param signame the signature's algorithm (e.g."MD5withRSA")
     * @param algorithm encryption algorithm (e.g. "Rijndael")
     * @param seed for SecureRandom (optional)
     * @param strength the keysize in bits (e.g. 128)
     * @param mode encryption mode (e.g. "CBC")
     * @param padding padding scheme (e.g."PKCS7Padding")
     * @param bufferlength buffer length in bytes
     * @throws CryptoException encryption errors
     * @throws IOException I/O errors
     */
    public static void encryptAndSign(InputStream is
                                      , DataOutputStream daos
                                      , PublicKey receiverKey
                                      , PrivateKey signingKey
                                      , X509Certificate cert
                                      , String signame
                                      , String algorithm
                                      , byte[] seed
                                      , int strength
                                      , String mode
                                      , String padding
                                      , int bufferlength)
            throws CryptoException, IOException {

        SecureRandom secRand = null;
        KeyGenerator keyGen = null;
        Key symKey = null;
        Cipher outputCipher = null;

        SignatureOutputStream sigStr = null;
        DataOutputStream dataStr = null;

        try {
            Security.addProvider(new BouncyCastleProvider());

            secRand = Seed.getSecureRandom(seed);

            // Generate symmetric key
            keyGen = KeyGenerator.getInstance(algorithm, "BC");
            keyGen.init(strength, secRand);
            symKey = keyGen.generateKey();

            // Instantiate Symmetric cipher for encryption.
            outputCipher = Cipher.getInstance(algorithm + "/" + mode + "/" + padding, "BC");
            outputCipher.init(Cipher.ENCRYPT_MODE, symKey, secRand);

            // Get key and IV for cipher so that they can be later
            // encrypted to build a header.
            byte[] keyEnc = symKey.getEncoded();
            byte[] keyIV = outputCipher.getIV();

            byte[] lock = new byte[24];

            secRand.nextBytes(lock);

            // Setup Signature
            Signature sig = Signature.getInstance(signame, "BC");
            sig.initSign(signingKey, secRand); // Initialize with my private signing key.
            sig.update(lock); // put plain text of lock data into signature.

            // Setup RSA to encrypt secrets.
            Cipher rsaEng = Cipher.getInstance("RSA/None/OAEPPadding", "BC");
            rsaEng.init(Cipher.ENCRYPT_MODE, receiverKey, secRand);

            // Setup to process File.
            //FileInputStream        inStr = new FileInputStream(filename); // Source of plain text.
            //FileOutputStream       outStr = new FileOutputStream(newfilename); // Final output stream.
            sigStr = new SignatureOutputStream(daos, sig);
            dataStr = new DataOutputStream(sigStr);

            // Form HEADER for the encrypted string
            dataStr.writeShort(FILE_HEADER); // Write a file or string header.

            // Write out a block for the key of the cipher.
            dataStr.writeShort(KEY_BLOCK); // Block header.
            byte[] tmp = rsaEng.doFinal(keyEnc); // Encrypt it with RSA.
            dataStr.writeInt(tmp.length); // Write length.
            dataStr.write(tmp); // Write data.
            Clean.blank(tmp); // Erase tmp array.

            // Write out IV block
            dataStr.writeShort(IV_BLOCK);  // Block header
            tmp = rsaEng.doFinal(keyIV); // Encrypt with RSA.
            dataStr.writeInt(tmp.length); // Write length.
            dataStr.write(tmp); // Write data.
            Clean.blank(tmp); // Erase tmp array.

            // Write out lock data for SIGNATURE.
            dataStr.writeShort(LOCK_BLOCK); // Write header.
            tmp = outputCipher.doFinal(lock); // Encrypt with AES.
            dataStr.writeInt(tmp.length); // Write length.
            dataStr.write(tmp); // Write data.
            Clean.blank(tmp); // Erase tmp array.

            // Reset cipher back to original
            outputCipher.init(Cipher.ENCRYPT_MODE, symKey, new IvParameterSpec(keyIV)); // initialize with aes_key.

            // Encrypt the message
            int l = 0; // Universal length variable.
            byte[] buf = new byte[bufferlength]; // A buffer to work in.
            byte[] out = null; // Output buffer.

            // Read while length is > -1

            while ((l = is.read(buf)) > -1) {
                out = outputCipher.update(buf, 0, l); // Encrypt data.
                if (out != null) {
                    dataStr.writeShort(DATA_BLOCK); // Write data block header.
                    dataStr.writeInt(out.length); // Write length.
                    dataStr.write(out); // Write encrypted data.
                }
            }

            // This is the last block
            out = outputCipher.doFinal(); // Do final encryption.
            dataStr.writeShort(FINAL_DATA_BLOCK); // Write header.
            dataStr.writeInt(out.length); // Write length.
            dataStr.write(out); // Write Data.

            Clean.blank(buf); // Clear buffer.
            buf = null; // Set Null

            // Write out our certificate
            dataStr.writeShort(CERT_BLOCK); // Cert block header.
            tmp = cert.getEncoded(); // Get encoded in a byte array.
            dataStr.writeInt(tmp.length); // Write length.
            dataStr.write(tmp); // Write data.

            // Write out signature block
            dataStr.writeShort(SIG_BLOCK); // Write Header.
            dataStr.flush(); // Flush it..

            tmp = sig.sign(); // Get signature code.
            dataStr.writeInt(tmp.length); // Write length.
            dataStr.write(tmp); // Write data.
            Clean.blank(tmp); // Clear.

            // Flush and close output.
            dataStr.flush();
            dataStr.close();
        } catch (IOException ioe) {
            ioe.printStackTrace();
            throw new IOException(ioe.getMessage());
        } catch (Exception ex) {
            ex.printStackTrace();
            throw new CryptoException(ex.getMessage());
        } finally {
            if (dataStr != null) {
                try {
                    dataStr.close();
                } catch (IOException ioe) {
                    ;
                }
            }
        }
    }

    /**
     * decrypt and verify text signature
     *
     * @param text the text to decrypt and verify
     * @param privKey the private key of the receiver
     * @param signercert returns the signer's certificate
     * @param signame the signature's algorithm (e.g."MD5withRSA")
     * @param algorithm encryption algorithm (e.g. "Rijndael")
     * @param mode encryption mode (e.g. "CBC")
     * @param padding padding scheme (e.g."PKCS7Padding")
     * @return the plaintext
     * @throws HeaderException thrown when package header is broken
     * @throws InvalidSignatureException thrown when the signature is invalid
     * @throws CryptoException all encryption errors
     */
    public static StringBuffer decryptAndVerify(StringBuffer text
                                                , PrivateKey privKey
                                                , SignerCertificate signercert
                                                , String signame
                                                , String algorithm
                                                , String mode
                                                , String padding) throws HeaderException, InvalidSignatureException, CryptoException {

        ByteArrayOutputStream bao = null;
        DataOutputStream dao = null;

        try {
            bao = new ByteArrayOutputStream();
            dao = new DataOutputStream(bao);

            // decrypt & verify
            decryptAndVerify(new ByteArrayInputStream(Base64.decode(text.toString())), dao, privKey, signercert, signame, algorithm, mode, padding, BUFFERSIZE_TEXT);

            return new StringBuffer(new String(bao.toByteArray()));
        } catch (HeaderException he) {
            throw new HeaderException(he.getMessage());
        } catch (InvalidSignatureException ise) {
            throw new InvalidSignatureException(ise.getMessage());
        } catch (Exception ioe) {
            ioe.printStackTrace();
            throw new CryptoException(ioe.getMessage());
        } finally {
            if (dao != null) {
                // close outputstream
                try {
                    dao.close();
                } catch (IOException e) {
                    ;
                }
            }
        }
    }

    /**
     * decrypt and verify inputstream signature (which must support mark/reset)
     *
     * @param is the inputstream to decrypt and verify (NOTE: the inputstream must support mark/reset because it must be read three times)
     * @param daos the outputstream containing the deciphered data
     * @param privKey the private key of the receiver
     * @param signercert returns the signer's certificate
     * @param signame the signature's algorithm (e.g."MD5withRSA")
     * @param algorithm encryption algorithm (e.g. "Rijndael")
     * @param mode encryption mode (e.g. "CBC")
     * @param padding padding scheme (e.g."PKCS7Padding")
     * @param bufferlength buffer length in bytes
     * @throws IOException I/O errors
     * @throws HeaderException thrown when package header is broken
     * @throws InvalidSignatureException thrown when the signature is invalid
     * @throws CryptoException all encryption errors
     */
    public static void decryptAndVerify(InputStream is
                                        , DataOutputStream daos
                                        , PrivateKey privKey
                                        , SignerCertificate signercert

?? 快捷鍵說明

復(fù)制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产精品91一区二区| 国产麻豆精品在线| 国产亚洲欧美在线| 欧美图区在线视频| 成人激情电影免费在线观看| 丝袜诱惑制服诱惑色一区在线观看 | 91网站在线观看视频| 亚洲高清视频的网址| 欧美成人在线直播| 91一区二区在线观看| 石原莉奈在线亚洲三区| 国产拍欧美日韩视频二区| 在线观看日韩av先锋影音电影院| 亚洲午夜影视影院在线观看| 欧美日高清视频| 成人精品一区二区三区四区| 亚瑟在线精品视频| 国产精品九色蝌蚪自拍| 3d成人h动漫网站入口| 国产成人av电影免费在线观看| 亚洲麻豆国产自偷在线| 久久在线观看免费| 91成人免费电影| 国产精品一区二区在线观看不卡 | 成人三级在线视频| 日精品一区二区三区| 中文字幕第一页久久| 欧美精品123区| 91蜜桃传媒精品久久久一区二区| 久久精品免费观看| 亚洲成人资源网| 亚洲欧洲日本在线| 久久久五月婷婷| 91精品国产综合久久精品| 色哟哟国产精品| 成人精品高清在线| 国产精品一卡二| 久久99国产精品麻豆| 亚洲欧美激情插| 欧美嫩在线观看| 色婷婷亚洲精品| 91一区二区三区在线观看| 国产999精品久久| 日本午夜精品视频在线观看| 婷婷久久综合九色综合绿巨人| 欧美国产日韩a欧美在线观看| 91精品国产丝袜白色高跟鞋| 欧美日韩高清一区二区不卡| 色视频欧美一区二区三区| 91尤物视频在线观看| 成人免费高清在线| 国产精品亚洲一区二区三区在线| 日本美女一区二区三区视频| 亚洲一区二区视频在线观看| 亚洲人吸女人奶水| 亚洲欧洲精品一区二区精品久久久| 久久精品亚洲乱码伦伦中文| www成人在线观看| 久久久久久久久久久黄色| 日韩视频一区在线观看| 欧美一卡二卡三卡| 欧美一区二视频| 91麻豆精品国产91久久久久久久久 | 久久综合狠狠综合| 久久先锋影音av鲁色资源网| 日韩午夜av电影| 日韩欧美国产一区在线观看| 337p日本欧洲亚洲大胆色噜噜| 日韩一二三区视频| 精品日韩在线一区| 久久嫩草精品久久久精品一| 精品国产乱码久久久久久免费| 欧美成人精品福利| 久久精品日产第一区二区三区高清版 | 丁香亚洲综合激情啪啪综合| 久久se这里有精品| 国产一区二区三区免费在线观看| 国产一区欧美一区| 国产成人av电影在线| 不卡的电影网站| 色视频一区二区| 欧美丰满少妇xxxbbb| 欧美大片顶级少妇| 日本一区二区三级电影在线观看| 国产精品日产欧美久久久久| 亚洲视频综合在线| 丝袜亚洲另类丝袜在线| 精品一区二区免费在线观看| 成人一区二区三区| 在线免费观看日本欧美| 欧美一区二区三区日韩视频| 久久综合久色欧美综合狠狠| 亚洲国产激情av| 性做久久久久久免费观看| 精品一区免费av| 色欧美乱欧美15图片| 精品少妇一区二区三区免费观看| 国产精品三级电影| 日本女人一区二区三区| 丰满亚洲少妇av| 欧美日韩国产片| 中文字幕乱码日本亚洲一区二区 | 久久综合色综合88| 国产无遮挡一区二区三区毛片日本| 国产精品第13页| 偷窥国产亚洲免费视频| 国产成人超碰人人澡人人澡| 在线免费观看日本一区| 制服丝袜日韩国产| 国产精品系列在线| 亚洲成人免费视| 大尺度一区二区| 日本道色综合久久| 日韩三级中文字幕| 亚洲欧美欧美一区二区三区| 日本大胆欧美人术艺术动态| 99久久精品免费| www激情久久| 天天爽夜夜爽夜夜爽精品视频| 成人av在线影院| 欧美电影免费观看高清完整版在| 亚洲精品中文字幕在线观看| 国产乱码精品1区2区3区| 欧美性videosxxxxx| 国产精品久久久久久久岛一牛影视 | 精品制服美女久久| 欧美日韩久久一区二区| 中文字幕中文在线不卡住| 久久精品国产澳门| 欧美日韩在线播放三区四区| 国产精品久久久久久久久免费桃花| 老司机精品视频导航| 欧美人与禽zozo性伦| 亚洲卡通动漫在线| av中文字幕亚洲| 欧美韩国日本综合| 国产一区999| 久久综合一区二区| 久久精品999| 日韩欧美一二三四区| 亚洲午夜精品一区二区三区他趣| 91丨九色丨黑人外教| 中文字幕亚洲区| 大尺度一区二区| 国产精品午夜久久| 成人三级伦理片| 国产日韩欧美激情| 国产精品原创巨作av| 欧美电影免费观看高清完整版| 亚洲激情综合网| 欧美在线一区二区| 亚洲国产人成综合网站| 91首页免费视频| 一区二区激情视频| 在线视频一区二区免费| 一区二区高清在线| 色婷婷激情一区二区三区| 久久久国产精品午夜一区ai换脸| 国产在线一区二区| 亚洲精品成人精品456| 97精品超碰一区二区三区| 国产女主播视频一区二区| 国产精品2024| 国产欧美一区二区在线| 国产激情一区二区三区桃花岛亚洲| 欧美区一区二区三区| 亚洲第一久久影院| 在线成人av网站| 亚洲在线一区二区三区| 欧美日韩综合不卡| 蜜臀av在线播放一区二区三区| 日韩欧美成人一区| 国产精品中文欧美| 亚洲欧美另类综合偷拍| 在线观看中文字幕不卡| 亚洲午夜免费电影| 日韩免费性生活视频播放| 国产最新精品精品你懂的| 久久精品一区八戒影视| 97se亚洲国产综合在线| 一区二区久久久久| 欧美一级日韩一级| 国内精品免费**视频| 亚洲国产精品黑人久久久| 色欧美片视频在线观看| 日本中文字幕一区二区视频| 精品国产91乱码一区二区三区 | 欧美久久一二区| 久久99精品久久久久久动态图| 精品国产自在久精品国产| 极品少妇xxxx偷拍精品少妇| 久久精品欧美日韩精品| 99视频超级精品| 日日夜夜免费精品视频| 欧美成人一区二区三区片免费| 国产精品一区二区在线播放| 亚洲黄色免费网站| 精品国产乱码久久久久久影片| 99re在线视频这里只有精品| 日韩av在线发布|