zoukankan      html  css  js  c++  java
  • RSA算法理解

    以下是自动生成moduls,公钥,私钥的相关代码:(仅供参考

    import java.security.KeyPair;

    import java.security.KeyPairGenerator;

    import java.security.NoSuchAlgorithmException;

    import java.security.interfaces.RSAPrivateKey;

    import java.security.interfaces.RSAPublicKey;

    public class Encrypt {

    public static void main(String[] args) {

    try {

    KeyPairGenerator rsa = KeyPairGenerator.getInstance("RSA");

    KeyPair pair = rsa.generateKeyPair();

    System.out.println("mod:"+((RSAPublicKey)pair.getPublic()).getModulus().toString());

    System.out.println("公钥:"+((RSAPublicKey)pair.getPublic()).getPublicExponent().toString());

    System.out.println("私钥:"+((RSAPrivateKey)pair.getPrivate()).getPrivateExponent().toString());

    } catch (NoSuchAlgorithmException e) {

    // TODO Auto-generated catch block

    e.printStackTrace();

    }

    }

    }

  • 相关阅读:
    JSP 隐含对象
    Cookie 和 Session
    Servlet(Server Applet) 详解
    AbstractQueuedSynchronizer 详解
    ThreadLocal 详解
    线程的生命周期
    phpfor函数和foreach函数
    php的while函数
    php的switch函数
    php的if函数
  • 原文地址:https://www.cnblogs.com/mxzhan/p/13340911.html
Copyright © 2011-2022 走看看