static void Main(string[] args)
        {
            bool     pass = false;
            string   mensaje;
            string   semilla;
            BitArray cifrado;



            do
            {
                Console.WriteLine("Introduzca el mensaje: ");
                mensaje = Console.ReadLine();
                pass    = check_binary(mensaje);
            }while(pass == false);

            semilla = "01101010101010101010111110100110101010101010100101011111010111100010101010101010010001111101011010100101010100010101010101011010";



            BitArray seed    = new BitArray(semilla.Length);
            BitArray message = new BitArray(mensaje.Length);



            seed    = convert_to_bool(seed, semilla);
            message = convert_to_bool(message, mensaje);

            E0 algoritmo = new E0(message, seed);

            algoritmo.crear_cadena_cifrante();
            BitArray S = algoritmo.get_S();

            Console.WriteLine("El mensaje Es: ");
            show_chipher(message);
            Console.WriteLine("La cadena cifrante es : ");
            show_chipher(S);
            cifrado = algoritmo.cifrar();
            Console.WriteLine("El mensaje cifrado es : ");
            show_chipher(cifrado);

            Console.WriteLine("------------------------------------------");
            BitArray descifrado = algoritmo.descifrar();

            Console.WriteLine("El mensaje cifrado es : ");
            show_chipher(cifrado);
            Console.WriteLine("El vector cifrante (S) es : ");
            show_chipher(S);
            Console.WriteLine("El mensaje descifrado es : ");
            show_chipher(descifrado);
        }
示例#2
0
        /// <summary>
        /// Check whether point is contained inside triangle.
        /// </summary>
        /// <param name="a_pos"></param>
        /// <returns></returns>
        public bool Contains(Vector2 a_pos)
        {
            // edge case when pos is on boundary triangle
            if (E0.IsOnSegment(a_pos) || E1.IsOnSegment(a_pos) || E2.IsOnSegment(a_pos))
            {
                return(true);
            }

            int firstSide  = MathUtil.Orient2D(P0, P1, a_pos);
            int secondSide = MathUtil.Orient2D(P1, P2, a_pos);
            int thirdSide  = MathUtil.Orient2D(P2, P0, a_pos);

            return(firstSide != 0 && firstSide == secondSide && secondSide == thirdSide);
        }
示例#3
0
        public void ZeroOneRemoval()
        {
            var x  = VF("x");
            var ex = Ex.Block(Ex.Add(x, E1), Ex.Add(x, E0), E1.Mul(x), x.Mul(E0), x.Sub(E0), E0.Sub(x));

            AreEqual("((x+1);\n(x+0);\n(1*x);\n(x*0);\n(x-0);\n(0-x);)", ex.Debug());
            AreEqual("((x+1);\nx;\nx;\n0;\nx;\n(0-x);)", ex.FlatDebug());
        }
示例#4
0
 /// <summary>
 /// Returns true if the number is even.
 /// </summary>
 public static tbool Even(tfloat b) => E0.Eq(z1Mod(b));
示例#5
0
 public static tbool DivBy(tfloat by, tfloat x) => E0.Eq(Mod(by, x));