public int powerMod(String binaryKey, Integer caracter, Double n){
        BigInteger a = BigInteger.valueOf(caracter);
        BigInteger aux =  BigInteger.valueOf((int)caracter);
        for (int i=1;i<binaryKey.length();i++){
            System.out.print( aux +" ");  
            if(binaryKey.charAt(i)=='1'){
                aux = ((aux.pow(2)).multiply(a)).remainder(BigInteger.valueOf(n.longValue()));
            }else{
                aux = (aux.pow(2)).remainder(BigInteger.valueOf(n.longValue()));
            }
        }
        System.out.print( aux +" = "+ aux.intValue());  
        System.out.println("");  
//        System.out.println("aux "+ aux);        
        return aux.intValue();
    }