Skip to content

Encryption

This abstract class contains necessary components for generating encryption keys.

Fields

CIPHER_TRANSFORM

java
protected final String CIPHER_TRANSFORM = "AES/GCM/NoPadding"

Defines the encryption algorithm for ciphers.

KEY_ALGO

java
private static final String KEY_ALGO = "PBKDF2WithHmacSHA256";

Defines the encryption algorithm

KEY_PASSWORD

java
private static final String KEY_PASSWORD = "<some password>";

Defines the PBKDF2 password

KEY_SPEC_ITER

java
private static final int KEY_SPEC_ITER = 65536;

Defines how many iterations the encryption will go through.

KEY_SPEC_LEN

java
private static final int KEY_SPEC_LEN = 256;

Defines the KeySpec length.

data

java
protected String data;

The data to be encrypted.

key

java
protected SecretKey key;

The SecretKey to be generated by this class.

salt

java
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

java
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()

java
protected void initKey()

The method that generates the SecretKey