-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKey.java
More file actions
29 lines (23 loc) · 699 Bytes
/
Copy pathKey.java
File metadata and controls
29 lines (23 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package blockchain;
import java.security.*;
public class Key {
private KeyPairGenerator keyGen;
private KeyPair pair;
private PrivateKey privateKey;
private PublicKey publicKey;
public Key(int keylength) throws NoSuchAlgorithmException{
this.keyGen = KeyPairGenerator.getInstance("RSA");
this.keyGen.initialize(keylength);
}
public void createKeys(){
this.pair = this.keyGen.generateKeyPair();
this.privateKey = pair.getPrivate();
this.publicKey = pair.getPublic();
}
public PrivateKey getPrivateKey(){
return this.privateKey;
}
public PublicKey getPublicKey(){
return this.publicKey;
}
}