public class CryptoHelper extends Object
| Constructor and Description |
|---|
CryptoHelper() |
| Modifier and Type | Method and Description |
|---|---|
static void |
decrypt(InputStream inputStream,
OutputStream outputStream,
String password)
Decrypt encrypted data from stream with password.
|
static void |
decrypt(InputStream inputStream,
OutputStream outputStream,
String recipientId,
PrivateKey privateKey)
Decrypt encrypted data from stream with private key.
|
static void |
decrypt(InputStream inputStream,
OutputStream outputStream,
String recipientId,
PrivateKey privateKey,
Password password)
Decrypt encrypted data from stream with private key.
|
static String |
decrypt(String base64Text,
String password)
Decrypt text with password.
|
static String |
decrypt(String base64Text,
String recipientId,
PrivateKey privateKey)
Decrypt text with private key.
|
static String |
decrypt(String base64Text,
String recipientId,
PrivateKey privateKey,
Password password)
Decrypt text with private key which protected with password.
|
static void |
encrypt(InputStream inputStream,
OutputStream outputStream,
String password)
Encrypt stream data with password.
|
static void |
encrypt(InputStream inputStream,
OutputStream outputStream,
String recipientId,
PublicKey publicKey)
Encrypt stream data with password.
|
static String |
encrypt(String text,
Map<String,PublicKey> recipients)
Encrypt text with public key for multiple recipients.
|
static String |
encrypt(String text,
String password)
Encrypt text with password.
|
static String |
encrypt(String text,
String recipientId,
PublicKey publicKey)
Encrypt text with public key.
|
static String |
sign(InputStream inputStream,
PrivateKey privateKey)
Sign stream with private key.
|
static String |
sign(InputStream inputStream,
PrivateKey privateKey,
String keyPassword)
Sign stream with private key protected with password.
|
static String |
sign(String text,
PrivateKey privateKey)
Sign text with private key.
|
static String |
sign(String text,
PrivateKey privateKey,
Password password)
Sign text with private key.
|
static String |
signBase64(String base64string,
PrivateKey privateKey)
Sign Base64 encoded string with private key.
|
static boolean |
verify(InputStream inputStream,
String signature,
PublicKey publicKey)
Verify stream data with signature.
|
static boolean |
verify(String text,
String signature,
PublicKey publicKey)
Verify text with signature.
|
static boolean |
verifyBase64(String base64string,
String signature,
PublicKey publicKey)
Verify Base664 encoded string with signature.
|
public static String encrypt(String text, String password) throws Exception
text - the text to be encrypted.password - the password used for encryption.Exceptionpublic static void encrypt(InputStream inputStream, OutputStream outputStream, String password) throws Exception
inputStream - the input stream to be encrypted.outputStream - the output stream encrypted data written to.password - the password used for encryption.Exceptionpublic static String encrypt(String text, String recipientId, PublicKey publicKey) throws Exception
text - the text to be encrypted.recipientId - the recipient ID.publicKey - the public key of recipient.Exceptionpublic static void encrypt(InputStream inputStream, OutputStream outputStream, String recipientId, PublicKey publicKey) throws Exception
inputStream - the input stream to be encrypted.outputStream - the output stream encrypted data written to.recipientId - the recipient ID.publicKey - the public key of recipient.Exceptionpublic static String encrypt(String text, Map<String,PublicKey> recipients) throws Exception
public static String decrypt(String base64Text, String password) throws Exception
base64Text - encrypted data as Base64 string.password - the password used for decryption.Exceptionpublic static void decrypt(InputStream inputStream, OutputStream outputStream, String password) throws Exception
inputStream - the input stream to be decrypted.outputStream - decrypted data will be written to this stream.password - the password used for data decryption.Exceptionpublic static String decrypt(String base64Text, String recipientId, PrivateKey privateKey) throws Exception
base64Text - encrypted data as Base64 string.recipientId - the recipient ID.privateKey - the private key of recipient.Exceptionpublic static void decrypt(InputStream inputStream, OutputStream outputStream, String recipientId, PrivateKey privateKey) throws Exception
inputStream - the input stream to be decrypted.outputStream - decrypted data will be written to this stream.recipientId - the recipient ID.privateKey - the private key of recipient.Exceptionpublic static String decrypt(String base64Text, String recipientId, PrivateKey privateKey, Password password) throws Exception
base64Text - encrypted data as Base64 string.recipientId - the recipient ID.privateKey - the private key of recipient.password - the private key's password.Exceptionpublic static void decrypt(InputStream inputStream, OutputStream outputStream, String recipientId, PrivateKey privateKey, Password password) throws Exception
inputStream - the input stream to be decrypted.outputStream - decrypted data will be written to this stream.recipientId - the recipient ID.privateKey - the private key of recipient.password - the private key's password.Exceptionpublic static String sign(String text, PrivateKey privateKey) throws Exception
text - the text to be signed.privateKey - the private key.Exceptionpublic static String sign(InputStream inputStream, PrivateKey privateKey) throws Exception
inputStream - the stream to be signed.privateKey - the private key.Exceptionpublic static String sign(InputStream inputStream, PrivateKey privateKey, String keyPassword) throws Exception
inputStream - the stream to be signed.privateKey - the private key.keyPassword - the private key password.Exceptionpublic static String signBase64(String base64string, PrivateKey privateKey) throws Exception
base64string - the Base64 encoded string to be signed.privateKey - the private key.Exceptionpublic static String sign(String text, PrivateKey privateKey, Password password) throws Exception
text - the text to be signed.privateKey - the private key.password - the private key's password.Exceptionpublic static boolean verify(String text, String signature, PublicKey publicKey) throws Exception
text - the text to be signed.signature - the sign as Base64 string.publicKey - the public key used for verification.Exceptionpublic static boolean verify(InputStream inputStream, String signature, PublicKey publicKey) throws Exception
inputStream - the stream to be signed.signature - the sign as Base64 string.publicKey - the public key used for verification.true if verification success.Exceptionpublic static boolean verifyBase64(String base64string, String signature, PublicKey publicKey) throws Exception
base64string - the Base64 string to be signed.signature - the sign as Base64 string.publicKey - the public key used for verification.ExceptionCopyright © 2016. All rights reserved.