package moduly.file.cruptlog;

import javax.crypto.spec.IvParameterSpec;
import javax.crypto.spec.SecretKeySpec;
import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;

public class ShiperKey implements ShiperInter {


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

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

    @Override
    public IvParameterSpec getIvKey() throws UnsupportedEncodingException {
        IvParameterSpec iv = new IvParameterSpec(initVector.getBytes(StandardCharsets.UTF_8)); // initVector
        return iv;
    }

    @Override
    public SecretKeySpec getSkeySpec() throws UnsupportedEncodingException {
        SecretKeySpec skeySpec = new SecretKeySpec(key.getBytes(StandardCharsets.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(StandardCharsets.UTF_8), "AES");

        return skeySpec;
    }
}
