public class PasswdEncryption extends Object
Modifier and Type | Field and Description |
---|---|
static int |
MAX_ENCRYPTION_LENGHT |
Constructor and Description |
---|
PasswdEncryption() |
Modifier and Type | Method and Description |
---|---|
static byte[] |
decrypt(byte[] text,
PrivateKey key)
Decrypt a sequence of bytes.
|
static String |
decrypt(String text,
PrivateKey key)
Decrypt a text.
|
static byte[] |
encrypt(byte[] text)
Encrypt a sequence of bytes a default public key.
|
static byte[] |
encrypt(byte[] text,
PublicKey key)
Encrypt a sequence of bytes.
|
static String |
encrypt(String text)
Encrypt a text with a default public key.
|
static String |
encrypt(String text,
PublicKey key)
Encrypt a text.
|
public static final int MAX_ENCRYPTION_LENGHT
public static String encrypt(String text) throws IOException, GeneralSecurityException
text
- text to encryptIOException
- when I/O error occursGeneralSecurityException
- when transformation error occurspublic static byte[] encrypt(byte[] text) throws IOException, GeneralSecurityException
text
- byte array to encryptIOException
- when I/O error occursGeneralSecurityException
- when transformation error occurspublic static byte[] encrypt(byte[] text, PublicKey key) throws IOException, GeneralSecurityException
text
- byte array to encryptkey
- the public key used for the encryptionIOException
- when I/O error occursGeneralSecurityException
- when transformation error occurspublic static byte[] decrypt(byte[] text, PrivateKey key) throws IOException, GeneralSecurityException
text
- byte array to decryptkey
- the private key used for the decryptionIOException
- when I/O error occursGeneralSecurityException
- when transformation error occurspublic static String encrypt(String text, PublicKey key) throws IOException, GeneralSecurityException
text
- text to encryptkey
- the public key used for the encryptionIOException
- when I/O error occursGeneralSecurityException
- when transformation error occurspublic static String decrypt(String text, PrivateKey key) throws IOException, GeneralSecurityException
text
- text to decryptkey
- the private key used for the decryptionIOException
- when I/O error occursGeneralSecurityException
- when transformation error occurs