首页 > 编程语言 > 详细

Java生成公私钥对

时间:2015-12-21 18:04:10      阅读:160      评论:0      收藏:0      [点我收藏+]
    public static synchronized KeyPair generateRSAKeyPair(int keysize, BigInteger publicExponent) {
        try {
            keyPairGen.initialize(new RSAKeyGenParameterSpec(keysize, publicExponent), new SecureRandom());
            return keyPairGen.generateKeyPair();
        } catch (Exception var3) {
            LOGGER.error("生成模长 =" + keysize + ",指数=" + publicExponent + "的RSA密钥对失败", var3);
            return null;
        }
    }

sample:

    public static void main(String[] args) throws Exception {
        KeyPair keyp = RSAUtils.generateRSAKeyPair(1408, RSAKeyGenParameterSpec.F0);
        PrivateKey privateKey = keyp.getPrivate();
        PublicKey publicKey = keyp.getPublic();
    }

 

Java生成公私钥对

原文:http://www.cnblogs.com/frankyou/p/5063917.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!