public class SymmetricEncryptor
extends Object
| Constructor and Description |
|---|
SymmetricEncryptor() |
| Modifier and Type | Method and Description |
|---|---|
static InputStream |
decrypt(InputStream encryptedStream)
Uses the default key to decrypt an InputStream.
|
static InputStream |
decrypt(Key key,
InputStream encryptedStream)
Uses the specific key to decrypt an InputStream.
|
static String |
decrypt(Key key,
String encryptedStr)
Uses the specific key to decrypt string.
|
static String |
decrypt(String encryptedStr)
Uses the default key to decrypt string.
|
static void |
decryptFile(Key key,
String encryptedFile)
Uses the specific key to decrypt file.
|
static void |
decryptFile(String encryptedFile)
Uses the default key to decrypt file.
|
static String |
decryptPassword(Key key,
String encryptedStr)
Decrypts password.
|
static OutputStream |
encrypt(Key key,
OutputStream streamToEncrypt)
Encrypts the OutputStream using specific key.
|
static String |
encrypt(Key key,
String strToEncrypt)
Encrypts string using specific key.
|
static OutputStream |
encrypt(OutputStream streamToEncrypt)
Encrypts the OutputStream using default key.
|
static String |
encrypt(String strToEncrypt)
Encrypts string using default key.
|
static void |
encryptFile(Key key,
String fileToEncrypt)
Encrypts the file using specific key.
|
static void |
encryptFile(String fileToEncrypt)
Encrypts the file using default key.
|
static String |
encryptPassword(Key key,
String strToEncrypt)
Encrypts password.
|
static PublicKey |
getPublicKey(byte[] bytes,
String algorithm)
Builds the public key from the array of bytes key using given algorithm.
|
static SecretKey |
getSecretKey(String keyString)
Gets the SecretKey from the string.
|
public static InputStream decrypt(InputStream encryptedStream)
throws GeneralSecurityException
encryptedStream - the InputStreamGeneralSecurityException - the general security exceptionpublic static InputStream decrypt(Key key,
InputStream encryptedStream)
throws GeneralSecurityException
key - the encryption keyencryptedStream - the InputStreamGeneralSecurityException - the general security exceptionpublic static String decrypt(Key key,
String encryptedStr)
throws GeneralSecurityException
key - the encryption keyencryptedStr - the encrypted stringGeneralSecurityException - the general security exceptionpublic static String decrypt(String encryptedStr)
throws GeneralSecurityException
encryptedStr - the encrypted stringGeneralSecurityException - the general security exceptionpublic static void decryptFile(Key key,
String encryptedFile)
throws GeneralSecurityException
key - the encryption keyencryptedFile - the name of the encrypted fileGeneralSecurityException - the general security exceptionpublic static void decryptFile(String encryptedFile)
throws GeneralSecurityException
encryptedFile - the name of the encrypted fileGeneralSecurityException - the general security exceptionpublic static String decryptPassword(Key key,
String encryptedStr)
throws GeneralSecurityException
key - the keyencryptedStr - the encrypted passwordGeneralSecurityException - the general security exceptionpublic static OutputStream encrypt(Key key,
OutputStream streamToEncrypt)
throws GeneralSecurityException
key - the encryption keystreamToEncrypt - the OutputStream to encryptGeneralSecurityException - the general security exceptionpublic static String encrypt(Key key,
String strToEncrypt)
throws GeneralSecurityException
key - the encryption keystrToEncrypt - the string to encryptGeneralSecurityException - the general security exceptionpublic static OutputStream encrypt(OutputStream streamToEncrypt)
throws GeneralSecurityException
streamToEncrypt - the OutputStream to encryptGeneralSecurityException - the general security exceptionpublic static String encrypt(String strToEncrypt)
throws GeneralSecurityException
strToEncrypt - the string to encryptGeneralSecurityException - the general security exceptionpublic static void encryptFile(Key key,
String fileToEncrypt)
throws GeneralSecurityException
key - the encryption keyfileToEncrypt - the name of the file to encryptGeneralSecurityException - the general security exceptionpublic static void encryptFile(String fileToEncrypt)
throws GeneralSecurityException
fileToEncrypt - the name of the file to encryptGeneralSecurityException - the general security exceptionpublic static String encryptPassword(Key key,
String strToEncrypt)
throws GeneralSecurityException
key - the keystrToEncrypt - the password to encryptGeneralSecurityException - the general security exceptionpublic static PublicKey getPublicKey(byte[] bytes,
String algorithm)
throws InvalidKeySpecException,
NoSuchAlgorithmException
bytes - the bytesalgorithm - the algorithmInvalidKeySpecException - the invalid key spec exceptionNoSuchAlgorithmException - the no such algorithm exceptionpublic static SecretKey getSecretKey(String keyString)
throws GeneralSecurityException
keyString - the key stringGeneralSecurityException - the general security exceptionCopyright © 2010-2020 Toolsverse. All Rights Reserved.