Package top.focess.util
Class RSA
- java.lang.Object
-
- top.focess.util.RSA
-
public class RSA extends Object
This is an RSA util class.
-
-
Constructor Summary
Constructors Constructor Description RSA()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static byte[]decryptRSA(byte[] data, String key)Decrypt data with RSA private keystatic byte[]encryptRSA(byte[] data, String key)Encrypt data with RSA public keystatic RSAKeypairgenRSAKeypair()Generate RSA key pairstatic byte[]sign(byte[] data, String k)Sign data with RSA private keystatic booleanverify(byte[] data, String k, byte[] sign)Verify sign with RSA public key
-
-
-
Method Detail
-
genRSAKeypair
public static RSAKeypair genRSAKeypair()
Generate RSA key pair- Returns:
- the RSA key pair
-
encryptRSA
public static byte[] encryptRSA(byte[] data, String key)Encrypt data with RSA public key- Parameters:
data- the data to encryptkey- the RSA public key- Returns:
- the encrypted data
-
decryptRSA
public static byte[] decryptRSA(byte[] data, String key)Decrypt data with RSA private key- Parameters:
data- the data to decryptkey- the RSA private key- Returns:
- the decrypted data
-
sign
public static byte[] sign(byte[] data, String k)Sign data with RSA private key- Parameters:
data- the data to signk- the RSA private key- Returns:
- the signed data
-
verify
public static boolean verify(byte[] data, String k, byte[] sign)Verify sign with RSA public key- Parameters:
data- the data to verifyk- the RSA public keysign- the sign to verify- Returns:
- true if the sign is valid, false otherwise
-
-