package admin.cryptor;

import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;

public class ShiperKey implements ShiperInter {


    private final String initVector = "fhDN7oxj$dfymY3n";
    private final String algorithm = "AES/CBC/PKCS5Padding";
    private String key;

    public ShiperKey(String key1) {
        key = key1;
    }

    @Override
    public IvParameterSpec getIvKey() throws UnsupportedEncodingException {
        IvParameterSpec iv = new IvParameterSpec(initVector.getBytes("UTF-8")); // initVector
        return iv;
    }

    @Override
    public SecretKeySpec getSkeySpec() throws UnsupportedEncodingException {
        SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");

        return skeySpec;
    }

    @Override
    public String getAlgorithm() {
        return algorithm;
    }


    @Override
    public SecretKeySpec getReturnSkeySpec(String key) throws UnsupportedEncodingException {
        SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes("UTF-8"), "AES");

        return skeySpec;
    }
}
