// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/exception/EncryptionException.java
// public class EncryptionException extends Exception {
// 
//     public EncryptionException(final String msg) {
//         super(msg);
//     }
// 
// }


import com.vecsight.dragonite.sdk.exception.EncryptionException;
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;
/*
 * The Dragonite Project
 * -------------------------
 * See the LICENSE file in the root directory for license information.
 */


package com.vecsight.dragonite.sdk.cryptor;



public class AESCryptor implements PacketCryptor {

    private static final int IV_LENGTH = 16;

    private static final int PADDING_LENGTH = 16;

    private static final String ENCRYPTION_ALGORITHM = "AES";

    private static final String ENCRYPTION_ALGORITHM_WITH_MODE = "AES/CBC/PKCS5Padding";

    private static final String PASSWORD_HASH_ALGORITHM = "PBKDF2WithHmacSHA1";

    private static final byte[] PASSWORD_HASH_SALT = "*1w@UTcZLS@6fS713x80".getBytes(StandardCharsets.UTF_8);

    private static final int PASSWORD_HASH_ITERATION_COUNT = 12450;

    private static final int PASSWORD_HASH_LENGTH_BITS = 128;

    private final SecretKeySpec keySpec;

    private final Cipher decryptionCipher;

    private final Cipher encryptionCipher;

    private final SecureRandom random = new SecureRandom();

// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/exception/EncryptionException.java
// public class EncryptionException extends Exception {
// 
//     public EncryptionException(final String msg) {
//         super(msg);
//     }
// 
// }


// Path: dragonite-sdk/src/main/java/com/vecsight/dragonite/sdk/cryptor/AESCryptor.java
import com.vecsight.dragonite.sdk.exception.EncryptionException;
import javax.crypto.*;
import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.PBEKeySpec;
import javax.crypto.spec.SecretKeySpec;
import java.nio.BufferUnderflowException;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import java.security.InvalidAlgorithmParameterException;
import java.security.InvalidKeyException;
import java.security.NoSuchAlgorithmException;
import java.security.SecureRandom;
import java.security.spec.InvalidKeySpecException;
import java.security.spec.KeySpec;

/*
 * The Dragonite Project
 * -------------------------
 * See the LICENSE file in the root directory for license information.
 */


package com.vecsight.dragonite.sdk.cryptor;



public class AESCryptor implements PacketCryptor {

    private static final int IV_LENGTH = 16;

    private static final int PADDING_LENGTH = 16;

    private static final String ENCRYPTION_ALGORITHM = "AES";

    private static final String ENCRYPTION_ALGORITHM_WITH_MODE = "AES/CBC/PKCS5Padding";

    private static final String PASSWORD_HASH_ALGORITHM = "PBKDF2WithHmacSHA1";

    private static final byte[] PASSWORD_HASH_SALT = "*1w@UTcZLS@6fS713x80".getBytes(StandardCharsets.UTF_8);

    private static final int PASSWORD_HASH_ITERATION_COUNT = 12450;

    private static final int PASSWORD_HASH_LENGTH_BITS = 128;

    private final SecretKeySpec keySpec;

    private final Cipher decryptionCipher;

    private final Cipher encryptionCipher;

    private final SecureRandom random = new SecureRandom();

    public AESCryptor(final String password) throws EncryptionException {