Class RSA
java.lang.Object
com.codingapi.springboot.framework.crypto.RSA
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
-
Field Details
-
KEY_ALGORITHM
- See Also:
-
-
Constructor Details
-
RSA
- Throws:
NoSuchAlgorithmException
-
RSA
-
RSA
-
RSA
- Throws:
Exception
-
RSA
- Throws:
Exception
-
-
Method Details
-
generateKey
Generate key which contains a pair of privae and public key using 2048 bytes- Returns:
- key pair
- Throws:
NoSuchAlgorithmException
-
getPrivateKey
public byte[] getPrivateKey() -
getPublicKey
public byte[] getPublicKey() -
encrypt
Encrypt a text using public key.- Parameters:
text- The original unencrypted text- Returns:
- Encrypted text
- Throws:
Exception
-
decrypt
Decrypt text using private key- Parameters:
text- The encrypted text- Returns:
- The unencrypted text
- Throws:
Exception
-