package moduly.decrypt;



import javax.crypto.Cipher;
import javax.crypto.SecretKey;
import javax.crypto.spec.IvParameterSpec;
import java.util.Base64;

public class DecruptStr {

    public String decryptor(String algorithm, String cipherText, SecretKey key, // java -jar <jar-file-names>.jar
                        IvParameterSpec iv) throws Exception {

        Cipher cipher = Cipher.getInstance(algorithm);
        cipher.init(Cipher.DECRYPT_MODE, key, iv);
        byte[] plainText = cipher.doFinal(Base64.getDecoder()
                .decode(cipherText));
        return new String(plainText);
    }

    public String decryptorBase64(String input) {
        byte[] decodedBytes = Base64.getDecoder().decode(input);
        String dec = new String(decodedBytes);
        return dec;
    }

}
