import javax.crypto.*;
import java.security.Key;

public class AES {
    public byte[] encryptCtr(Key key, byte[] pt) {
        try {
            Cipher c;
            c = Cipher.getInstance("AES/CTR/NoPadding");
            c.init(Cipher.ENCRYPT_MODE, key);
            return c.doFinal(pt);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }

    public byte[] decryptCtr(Key key, byte[] ct) {
        try {
            Cipher c;
            c = Cipher.getInstance("AES/CTR/NoPadding");
            c.init(Cipher.DECRYPT_MODE, key);
            return c.doFinal(ct);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}