Esempio n. 1
0
        static public string Decryptionstr(byte[] file, string key)
        {
            try
            {
                var     data     = Encoding.UTF8.GetString(file);
                Int32   aa       = Convert.ToInt32(key);
                int     y        = key.Length;
                long    t        = hashing(aa, y);
                var     finalKey = t.ToString();
                encrypt er       = new encrypt();
                var     en_file  = er.Decrypt(data, t.ToString("D8"));
                return(en_file);
            }
            catch (CryptographicException e)
            {
                Console.WriteLine(e.ToString());

                return(null);
            }
        }
Esempio n. 2
0
        static public byte[] Encryption(byte[] file, string key)
        {
            try
            {
                var   data = Encoding.UTF8.GetString(file);
                Int32 aa   = Convert.ToInt32(key);
                int   y    = key.Length;
                long  t    = hashing(aa, y);

                encrypt er      = new encrypt();
                var     en_file = er.crypt(t.ToString("D8"), file);
                var     enc     = er.Encrypt(data, t.ToString("D8"));
                var     dec     = er.Decrypt(enc, t.ToString("D8"));

                //return encryptedData;
                return(en_file);
            }
            catch (CryptographicException e)
            {
                Console.WriteLine(e.Message);

                return(null);
            }
        }