Java Code Examples for cn.hutool.crypto.SecureUtil#generateKeyPair()

The following examples show how to use cn.hutool.crypto.SecureUtil#generateKeyPair() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SecurityTools.java    From jeecg-cloud with Apache License 2.0 5 votes vote down vote up
public static MyKeyPair generateKeyPair(){
    KeyPair keyPair= SecureUtil.generateKeyPair(SignAlgorithm.SHA1withRSA.getValue(),2048);
    String priKey= Base64Encoder.encode(keyPair.getPrivate().getEncoded());
    String pubkey= Base64Encoder.encode(keyPair.getPublic().getEncoded());
    MyKeyPair resp=new MyKeyPair();
    resp.setPriKey(priKey);
    resp.setPubKey(pubkey);
    return resp;
}
 
Example 2
Source File: SecurityTools.java    From jeecg-boot-with-activiti with MIT License 5 votes vote down vote up
public static MyKeyPair generateKeyPair(){
    KeyPair keyPair= SecureUtil.generateKeyPair(SignAlgorithm.SHA1withRSA.getValue(),2048);
    String priKey= Base64Encoder.encode(keyPair.getPrivate().getEncoded());
    String pubkey= Base64Encoder.encode(keyPair.getPublic().getEncoded());
    MyKeyPair resp=new MyKeyPair();
    resp.setPriKey(priKey);
    resp.setPubKey(pubkey);
    return resp;
}
 
Example 3
Source File: SecurityTools.java    From teaching with Apache License 2.0 5 votes vote down vote up
public static MyKeyPair generateKeyPair(){
    KeyPair keyPair= SecureUtil.generateKeyPair(SignAlgorithm.SHA1withRSA.getValue(),2048);
    String priKey= Base64Encoder.encode(keyPair.getPrivate().getEncoded());
    String pubkey= Base64Encoder.encode(keyPair.getPublic().getEncoded());
    MyKeyPair resp=new MyKeyPair();
    resp.setPriKey(priKey);
    resp.setPubKey(pubkey);
    return resp;
}
 
Example 4
Source File: RsaKeyUtil.java    From netty-learning-example with Apache License 2.0 5 votes vote down vote up
/**
 * 生成私钥文件
 */
public static void main(String[] args) {
    System.out.println();
    System.out.print("输入保存密钥文件的路径(如: f:/rsa/): ");
    Scanner scanner = new Scanner(System.in);
    String path = scanner.nextLine();
    KeyPair keyPair = SecureUtil.generateKeyPair("RSA", 512, LocalDateTime.now().toString().getBytes());
    RSAPrivateKey privateKey = (RSAPrivateKey) keyPair.getPrivate();
    String privatePath = path + "auth-private.key";
    IoUtil.writeObjects(FileUtil.getOutputStream(privatePath), true, privateKey);
}
 
Example 5
Source File: SecurityTools.java    From jeecg-boot with Apache License 2.0 5 votes vote down vote up
public static MyKeyPair generateKeyPair(){
    KeyPair keyPair= SecureUtil.generateKeyPair(SignAlgorithm.SHA1withRSA.getValue(),2048);
    String priKey= Base64Encoder.encode(keyPair.getPrivate().getEncoded());
    String pubkey= Base64Encoder.encode(keyPair.getPublic().getEncoded());
    MyKeyPair resp=new MyKeyPair();
    resp.setPriKey(priKey);
    resp.setPubKey(pubkey);
    return resp;
}