JCA usage - xbacinsk/White-box_cipher_java GitHub Wiki
Secure environment - look-up tables generation
SecureRandom random = new SecureRandom();
byte[] keyData = new byte[]{
(byte)0x2b, (byte)0x7e, (byte)0x15, (byte)0x16, (byte)0x28, (byte)0xae, (byte)0xd2, (byte)0xa6,
(byte)0xd2, (byte)0xa6, (byte)0x2b, (byte)0x7e, (byte)0x15, (byte)0x16, (byte)0x28, (byte)0xae,
};
Key key = new SecretKeySpec(keyData, "WBAES");
AES_Cipher encryptor = new AES_Cipher();
try {
encryptor.engineInit(Cipher.ENCRYPT_MODE, key, random); //generates look-up tables for encryption
} catch (InvalidKeyException e) {}
AES_Cipher decryptor = new AES_Cipher();
try {
decryptor.engineInit(Cipher.DECRYPT_MODE, key, random); //generates look-up tables for decryption
} catch (InvalidKeyException e) {}
Insecure environment - tables loading and encryption/decryption
int iolength = 16;
SecureRandom random = new SecureRandom();
AES_Cipher encryptor = new AES_Cipher();
try {
encryptor.engineInit(Cipher.ENCRYPT_MODE, null, random); //loads look-up tables for encryption
} catch (InvalidKeyException e) {}
AES_Cipher decryptor = new AES_Cipher();
try {
decryptor.engineInit(Cipher.DECRYPT_MODE, null, random); //loads look-up tables for decryption
} catch (InvalidKeyException e) {}
byte[] outputEnc = new byte[iolength];
try {
outputEnc = encryptor.engineDoFinal(input /*byte array with length iolength*/, 0, iolength);
} catch (Exception e) {}
byte[] outputDec = new byte[iolength];
try {
outputDec = decryptor.engineDoFinal(outputEnc, 0, iolength);
} catch (Exception e) {}