Beispiel #1
0
        public string decrypt(string inputStr)
        {
            string str = "";

            try
            {
                byte[] data    = this.convertHex2Bytes(inputStr);
                byte[] buffer2 = StreamCipher.Encode(this.aesNow, data, StreamCipher.DECRYPT);
                str            = Encoding.Unicode.GetString(buffer2);
                this.plainText = str;
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error : " + exception);
            }
            return(str);
        }
Beispiel #2
0
        public string encrypt(string inputStr)
        {
            string str = "";

            try
            {
                byte[] bytes   = Encoding.Unicode.GetBytes(inputStr);
                byte[] buffer2 = StreamCipher.Encode(this.aesNow, bytes, StreamCipher.ENCRYPT);
                str             = this.convertBytes2String(buffer2);
                this.CipherText = str;
            }
            catch (Exception exception)
            {
                Console.WriteLine("Error : " + exception);
            }
            return(str);
        }
Beispiel #3
0
        // Methods
        public Encription()
        {
            this.plainText  = "";
            this.CipherText = "";
            int          keySize = 0x20;
            IBlockCipher aes     = AesFactory.GetAes();

            byte[] iv = new byte[aes.BlockSizeInBytes()];
            for (int i = 0; i < iv.Length; i++)
            {
                iv[i] = 0;
            }
            byte[] salt           = new byte[8];
            int    iterationCount = 0x400;
            long   num4           = DateTime.Now.Ticks;

            byte[] key = KeyGen.DeriveKey("ANIEncryptionLib", keySize, salt, iterationCount);
            num4        = DateTime.Now.Ticks - num4;
            this.aesNow = StreamCipher.MakeStreamCtx(aes, key, iv);
        }