FTP解密错误。建议我在c#中使用哪种算法进行ftp uploding [英] FTP decryption error. suggests me which algorithm is used for ftp uploding in c #

查看:69
本文介绍了FTP解密错误。建议我在c#中使用哪种算法进行ftp uploding的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

public static void EncryptFile(string inputFile, string outputFile, string skey)
        {
            RijndaelManaged aes = new RijndaelManaged();
            try
            {
                byte[] key = ASCIIEncoding.UTF8.GetBytes(skey);

                using (FileStream fsCrypt = new FileStream(outputFile, FileMode.Create))
                {
                    using (CryptoStream cs = new CryptoStream(fsCrypt, aes.CreateEncryptor(key, key), CryptoStreamMode.Write))
                    {
                        using (FileStream fsIn = new FileStream(inputFile, FileMode.Open))
                        {
                            int data;

                            while ((data = fsIn.ReadByte()) != -1)
                            {
                                cs.WriteByte((byte)data);
                            }

                            aes.Clear();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                aes.Clear();
            }
        }
private static void DecryptFile(string inputFile, string outputFile, string skey)
        {
            RijndaelManaged aes = new RijndaelManaged();

            try
            {
                byte[] key = ASCIIEncoding.UTF8.GetBytes(skey);

                using (FileStream fsCrypt = new FileStream(inputFile, FileMode.Open))
                {
                    using (FileStream fsOut = new FileStream(outputFile, FileMode.Create))
                    {
                        using (CryptoStream cs = new CryptoStream(fsCrypt, aes.CreateDecryptor(key, key), CryptoStreamMode.Read))
                        {
                            int data;

                            while ((data = cs.ReadByte()) != -1)
                            {
                                fsOut.WriteByte((byte)data);
                            }

                            aes.Clear();
                        }
                    }
                }

            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                aes.Clear();
            }
        }

推荐答案

请参阅我对该问题的评论。你在哪里尝试使用FTP?



请参阅这些CodeProject文章;你会找到你所需要的一切:

C#的FTP客户端库 [ ^ ],

FTP安全客户端库对于C# [ ^ ],

.NET 2.0的FTP客户端库 [ ^ ]。



-SA
Please see my comment to the question. Where are you trying to work with FTP?

Please see these CodeProject articles; you will find all you need:
FTP client library for C#[^],
An FTP secure client library for C#[^],
An FTP client library for .NET 2.0[^].

—SA


这篇关于FTP解密错误。建议我在c#中使用哪种算法进行ftp uploding的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆