Esempio n. 1
0
        public void testDecript()
        {
            TDESEncrypter.TDES tdes = new TDESEncrypter.TDES();


            string key = "153b07d1c925edca7f8d8431c9d32bd05ed22ed83be3aadb";
            string iv  = "c4cb5939841c4352";


            var keys = HexaToByteArray(key);
            var key1 = keys.Take(8).ToArray();
            var key2 = keys.Skip(8).Take(8).ToArray();
            var key3 = keys.Skip(16).Take(8).ToArray();


            tdes.setKeys(key1, key2, key3);
            tdes.setInitializationVector(HexaToByteArray(iv));


            var bytes = HexaToByteArray("052fc885070145fd");

            Console.WriteLine(bytes.ToString());
            var de = tdes.Decrypt(bytes);

            var textHex = System.Text.Encoding.UTF8.GetString(de);

            Console.WriteLine(textHex);
        }
Esempio n. 2
0
        public void testEncryption()
        {
            TDESEncrypter.TDES tdes = new TDESEncrypter.TDES();


            string key = "153b07d1c925edca7f8d8431c9d32bd05ed22ed83be3aadb";
            string iv  = "c4cb5939841c4352";


            var keys = HexaToByteArray(key);
            var key1 = keys.Take(8).ToArray();
            var key2 = keys.Skip(8).Take(8).ToArray();
            var key3 = keys.Skip(16).Take(8).ToArray();


            tdes.setKeys(key1, key2, key3);
            tdes.setInitializationVector(HexaToByteArray(iv));

            var en      = tdes.Encrypt("hola");
            var textHex = BitConverter.ToString(en).Replace("-", "");

            Console.WriteLine(textHex);
        }