Beispiel #1
0
        public static void Main(string[] args)
        {
            // RSA rsa = new RSA();
            // rsa.init(17, 23);
            // String s = "Hellooo world!!!";
            // byte[] input = System.Text.Encoding.ASCII.GetBytes(s);

            // byte[] iv = rsa.GenerateRandomIV();

            // byte[] cript1 = rsa.Crypt1(input);
            // byte[] cript = rsa.CryptBlock(input);

            // rsa.init(17,23);
            // byte[] decrypt1 = rsa.DecryptBlock(cript1);

            // String i1 = System.Text.Encoding.ASCII.GetString(iv);
            // String r1 = System.Text.Encoding.ASCII.GetString(cript);
            // String r2 = System.Text.Encoding.ASCII.GetString(decrypt1);

            // Console.WriteLine("cripr length: "+cript.Count());
            // Console.WriteLine("input length: "+input.Count());
            // Console.WriteLine("r1: "+r1);
            //// Console.WriteLine("r2: "+r2);
            // Console.ReadLine();

            Crypto.A5_2 a5  = new A5_2();
            byte[]      key = a5.GenerateRandomKey();
            byte[]      iv  = a5.GenerateRandomIV();

            a5.SetKey(key);
            a5.SetIV(iv);

            String s = "Hellooo world test !!!";

            byte[] input = System.Text.Encoding.Unicode.GetBytes(s);
            byte[] cript = a5.Crypt(input);

            String cr = System.Text.Encoding.Unicode.GetString(cript);

            byte[] crb = System.Text.Encoding.Unicode.GetBytes(cr);

            // Crypto.A5_2 a52 = new A5_2();
            a5.SetKey(key);
            a5.SetIV(iv);
            byte[] decrypt = a5.Decrypt(crb);
            String res     = System.Text.Encoding.Unicode.GetString(decrypt);

            Console.WriteLine("key: " + res);
            //Console.WriteLine("Length: " + key.Count());
            Console.ReadLine();
        }
Beispiel #2
0
        public CryptoService()
        {
            if (rc4 == null)
            {
                rc4 = new RC4();
            }

            if (rsa == null)
            {
                rsa = new RSA();
                //rsa.init(17, 23);
            }

            if (a5_2 == null)
            {
                a5_2 = new A5_2();
            }
        }
Beispiel #3
0
        void Main33(string[] args)
        {
            Crypto.A5_2 a5  = new A5_2();
            byte[]      key = a5.GenerateRandomKey();
            // byte[] iv = a5.GenerateRandomIV();

            a5.SetKey(key);
            // a5.SetIV(iv);

            String s = "Hellooo world!!!";

            byte[] input = System.Text.Encoding.ASCII.GetBytes(s);
            byte[] cript = a5.Crypt(input);

            Crypto.A5_2 a52 = new A5_2();
            a52.SetKey(key);
            //a52.SetIV(iv);
            byte[] decrypt = a52.Crypt(cript);
            String res     = System.Text.Encoding.ASCII.GetString(decrypt);

            RC4 rc4 = new RC4();

            byte[] iv = rc4.GenerateRandomIV();

            int counter = 1;

            // byte[] iv;
            byte[] output          = new byte[input.Length];
            int    IVCounterLength = iv.Count() + sizeof(int);

            byte[] ctr       = BitConverter.GetBytes(counter);
            byte[] IVCounter = { };
            IVCounter = IVCounter.Concat(iv).ToArray();
            IVCounter = IVCounter.Concat(ctr).ToArray();

            byte byte1 = 10;
            byte byte2 = 20;
            //  byte1[1] = byte1[1] ^ byte2[6];
            byte r = (byte)((byte1 >> 1 & 1) ^ (byte2 >> 6 & 1));

            byte[] b = System.Text.Encoding.ASCII.GetBytes("he lo");
            Console.WriteLine("Length: " + b.Count());
            Console.ReadLine();
        }