Encryption
This abstract class contains necessary components for generating encryption keys.
Fields
CIPHER_TRANSFORM
protected final String CIPHER_TRANSFORM = "AES/GCM/NoPadding"
Defines the encryption algorithm for ciphers.
KEY_ALGO
private static final String KEY_ALGO = "PBKDF2WithHmacSHA256";
Defines the encryption algorithm
KEY_PASSWORD
private static final String KEY_PASSWORD = "<some password>";
Defines the PBKDF2 password
KEY_SPEC_ITER
private static final int KEY_SPEC_ITER = 65536;
Defines how many iterations the encryption will go through.
KEY_SPEC_LEN
private static final int KEY_SPEC_LEN = 256;
Defines the KeySpec length.
data
protected String data;
The data to be encrypted.
key
protected SecretKey key;
The SecretKey
to be generated by this class.
salt
protected byte[] salt;
The salt of the encryption
INFO
A salt is basically a random set of bytes/characters that is concatenated to the text being encrypted before it is encrypted.
IMPORTANT
It is important that the decoder will have the same salt as the encryptor.
iv
protected byte[] iv;
The Initialization Vector (IV) of the encryption
INFO
IVs add randomness to the start of the encryption process.
IMPORTANT
It is important that the decoder will have the same IV as the encryptor.
Methods
initKey()
protected void initKey()
The method that generates the SecretKey