C#加密程序

using System;
using System.IO;
namespace JiaMi {
    public class main {
        public static void Main(string[] args) {
            string[] all_text = new string[1000000];
            int line = 0;
            Console.WriteLine("Please input the address:");
            string address = Console.ReadLine();
            try {
                using(StreamReader fin = new StreamReader(address)) {
                    string text;
                    while ((text = fin.ReadLine()) != null) {
                        all_text[line] = text;
                        line++;
                    }
                }
                Console.WriteLine("Read successfully!");
            }catch(Exception error) {
                Console.WriteLine(error.Message);
            }
            try {
                using(StreamWriter fout = new StreamWriter(address)) {
                    for (int i = 0; i < line; i++) {
                        for (int j = 0; j < all_text[i].Length; j++) {
                            char ch = all_text[i][j];
                            if ((ch >= 'a' && ch < 'z')||(ch >= 'A' && ch < 'Z')) {
                                ch = Convert.ToChar(ch+'b'-'a');
                            }else if (ch == 'z') {
                                ch = 'a';
                            }else if (ch == 'Z') {
                                ch = 'A';
                            }
                            fout.Write(ch);
                        }
                        fout.WriteLine();
                    }
                }
                Console.WriteLine("Write successfully!");
            }catch(Exception error) {
                Console.WriteLine(error.Message);
            }
            Console.Write("Press any key to continue...");
            Console.ReadKey();
            return;
        }
    }
}
全部评论

相关推荐

评论
1
收藏
分享
牛客网
牛客企业服务