public abstract class KeyObject extends Object
Modifier | Constructor and Description |
---|---|
protected |
KeyObject()
Empty constructor
|
Modifier and Type | Method and Description |
---|---|
byte[] |
crypt(byte[] plaintext)
Crypt one array of bytes and returns the crypted array of bytes
|
byte[] |
crypt(String plaintext)
Crypt one String and returns the crypted array of bytes
|
String |
cryptToHex(byte[] plaintext)
Crypt one array of bytes and returns the crypted String as HEX format
|
String |
cryptToHex(String plaintext)
Crypt one String and returns the crypted String as HEX format
|
byte[] |
decodeHex(String encoded) |
byte[] |
decrypt(byte[] ciphertext)
Decrypt an array of bytes and returns the uncrypted array of bytes
|
byte[] |
decryptHexFile(File file)
Decode from a file containing a HEX crypted string
|
byte[] |
decryptHexInBytes(byte[] ciphertext)
Decrypt an array of bytes as HEX format representing a crypted array of
bytes and returns the uncrypted
array of bytes
|
byte[] |
decryptHexInBytes(String ciphertext)
Decrypt a String as HEX format representing a crypted array of bytes and
returns the uncrypted array of
bytes
|
String |
decryptHexInString(byte[] ciphertext)
Decrypt a String as HEX format representing a crypted String and
returns the uncrypted String
|
String |
decryptHexInString(String ciphertext)
Decrypt a String as HEX format representing a crypted array of bytes and
returns the uncrypted String
|
String |
decryptInString(byte[] ciphertext)
Decrypt an array of bytes and returns the uncrypted String
|
String |
encodeHex(byte[] bytes) |
void |
generateKey()
Generate a key from nothing
|
abstract String |
getAlgorithm() |
abstract String |
getFileExtension() |
abstract String |
getInstance() |
abstract int |
getKeySize() |
Key |
getSecretKey() |
byte[] |
getSecretKeyInBytes()
Returns the key as an array of bytes in order to be stored somewhere else
and retrieved using the
setSecretKey(byte[] keyData) method.
|
boolean |
keyReady() |
void |
saveSecretKey(File file)
Save a Key to a File
|
void |
setSecretKey(byte[] keyData)
Reconstruct a key from an array of bytes
|
void |
setSecretKey(File file)
Create a Key from a File
|
void |
setSecretKey(Key secretKey)
Set the secretKey
|
Cipher |
toCrypt()
Returns a cipher for encryption associated with the key
|
Cipher |
toDecrypt()
Returns a cipher for decryption associated with the key
|
public abstract String getAlgorithm()
public abstract String getInstance()
public abstract int getKeySize()
public abstract String getFileExtension()
public Key getSecretKey()
public boolean keyReady()
public byte[] getSecretKeyInBytes()
public void setSecretKey(Key secretKey)
secretKey
- public void setSecretKey(byte[] keyData)
public void setSecretKey(File file) throws CryptoException, IOException
file
- CryptoException
IOException
public void saveSecretKey(File file) throws CryptoException, IOException
file
- CryptoException
IOException
public void generateKey() throws Exception
Exception
public Cipher toCrypt()
public byte[] crypt(byte[] plaintext) throws Exception
plaintext
- Exception
public String cryptToHex(byte[] plaintext) throws Exception
plaintext
- Exception
public byte[] crypt(String plaintext) throws Exception
plaintext
- Exception
public String cryptToHex(String plaintext) throws Exception
plaintext
- Exception
public Cipher toDecrypt()
public byte[] decrypt(byte[] ciphertext) throws Exception
ciphertext
- Exception
public String decryptInString(byte[] ciphertext) throws Exception
ciphertext
- Exception
public byte[] decryptHexInBytes(String ciphertext) throws Exception
ciphertext
- Exception
public byte[] decryptHexInBytes(byte[] ciphertext) throws Exception
ciphertext
- Exception
public String decryptHexInString(String ciphertext) throws Exception
ciphertext
- Exception
public String decryptHexInString(byte[] ciphertext) throws Exception
ciphertext
- Exception
public byte[] decryptHexFile(File file) throws Exception
file
- Exception
public byte[] decodeHex(String encoded)
encoded
- public String encodeHex(byte[] bytes)
bytes
- Copyright © 2009–2020 Waarp. All rights reserved.