public class Cipher extends Object
| Constructor and Description |
|---|
Cipher() |
| Modifier and Type | Method and Description |
|---|---|
int |
decrypt(byte[] cipherText,
byte[] plainText,
Key key,
byte[] iv)
Decrypts cipherText and stores the
plain text in plainText using private key for password
decryption or symmetric key for data decryption
|
int |
encrypt(byte[] plainText,
byte[] cipherText,
Key key)
Encrypts plain text and stores the
cipher text in cipherText using public key for password encryption.
|
static byte[] |
encryptData(byte[] plainText,
SecretKey key,
byte[] iv,
Cipher cipher)
Encrypts the plain text data message using "EAS256/CBC/PKCS7"
|
static Cipher |
getEASInstance(String algorithm) |
static Cipher |
getInstance() |
public static Cipher getInstance()
public int encrypt(byte[] plainText,
byte[] cipherText,
Key key)
throws SecurityException
plainText - - plain text to be encryptedcipherText - - encrypted plain text is returnedkey - - password encryption: public keySecurityExceptionpublic static Cipher getEASInstance(String algorithm) throws SecurityException
SecurityExceptionpublic static byte[] encryptData(byte[] plainText,
SecretKey key,
byte[] iv,
Cipher cipher)
throws SecurityException
plainText - - plain text to be encryptedkey - - session key is used as secret keyiv - - 16 lower bytes of the nonce is used as the initial vector.
Can't use the whole 32 bytes nonce because the IV size has
to be equal to the block size which is a Java requirement.SecurityExceptionpublic int decrypt(byte[] cipherText,
byte[] plainText,
Key key,
byte[] iv)
throws SecurityException
cipherText - cipher text to be decryptedplainText - decrypted cipher text is returnedkey - password decryption: private key
message encryption: session keyiv - 8 sequence nonce is used as the initial vector for symmetric
key encryption. Null if is private key encryptionSecurityExceptionCopyright © 2017. All Rights Reserved.