public class RsaMessage extends Object
| Constructor and Description |
|---|
RsaMessage() |
| Modifier and Type | Method and Description |
|---|---|
static byte[] |
decrypt(byte[] message,
Key key)
decrypt byte array to a string with key(RSA)
|
static String |
decryptAndBase64(String message,
Key key)
decrypt a string with key(Base64)
|
static String |
decryptWithRSA2048Key(byte[] data,
Key key)
decrypt a byte array to string with key(RSA/ECB/PKCS1Padding)<=the chosen one
|
static byte[] |
decryptWithRSA2048KeyGetType(byte[] data,
Key key) |
static byte[] |
encrypt(String message,
Key key)
encrypt a string to byte array with key(RSA)
|
static String |
encryptAndBase64(String message,
Key key)
encrypt a string with key(Base64)
|
static String |
encryptWithRSA2048Key(byte[] data,
Key key)
encrypt a byte array to string with key(RSA/ECB/PKCS1Padding)<=the chosen one
|
static byte[] |
getSHA1Digest(byte[] data) |
static Object |
readFromFile(String fileName)
read a object from a file(no use)
|
Key |
readKeyFromFile(String fileName,
boolean isPublic)
read key from a file with relative path
|
static byte[] |
sign(byte[] message,
PrivateKey key)
sign a xml string(encode or not)
|
static String |
signDsfwithSHA1AndRsa2048(byte[] data,
Key key)
new sign function
|
static boolean |
verify(byte[] data,
String sign,
PublicKey key)
verify a xml string(encode or not)
|
static boolean |
verifyDsfwithSHA512AndAES192(byte[] content,
byte[] sign,
Key key)
new verify function
|
public static byte[] encrypt(String message, Key key) throws Exception
message - key - Exceptionpublic static String encryptAndBase64(String message, Key key) throws Exception
message - key - Exceptionpublic static String encryptWithRSA2048Key(byte[] data, Key key)
data - key - public static byte[] decrypt(byte[] message,
Key key)
throws Exception
message - key - Exceptionpublic static String decryptAndBase64(String message, Key key) throws Exception
message - key - Exceptionpublic static String decryptWithRSA2048Key(byte[] data, Key key) throws Exception
data - key - Exceptionpublic static byte[] sign(byte[] message,
PrivateKey key)
throws Exception
message - key - Exceptionpublic static Object readFromFile(String fileName) throws Exception
fileName - Exceptionpublic Key readKeyFromFile(String fileName, boolean isPublic)
fileName - isPublic - public static String signDsfwithSHA1AndRsa2048(byte[] data, Key key) throws Exception
data - key - Exceptionpublic static boolean verifyDsfwithSHA512AndAES192(byte[] content,
byte[] sign,
Key key)
throws Exception
content - sign - key - Exceptionpublic static boolean verify(byte[] data,
String sign,
PublicKey key)
throws Exception
data - key - sign - ExceptionCopyright © 2014. All Rights Reserved.