教学服务系统

 找回密码
 立即注册
搜索
查看: 542|回复: 0

信息计算2019级1班20号李善安

[复制链接]

10

主题

18

帖子

108

积分

注册会员

Rank: 2

积分
108
发表于 2022-4-16 13:00:40 | 显示全部楼层 |阅读模式
先定义一个密钥,再实例化这个类。建好需要加密的文件1,以及两个空文件2,3用于存储加密后的以及解密的结果,并拿下文件路径。最后调用Encrypt方法加密文件1,结果存入文件2,调用Decrypt方法解密文件2,存入文件3.
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;

  6. namespace _3DES
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             string key = "lililililili";
  13.             TripleDES_ tripleDES_ = new TripleDES_(key);
  14.             Console.WriteLine("需要加密的文件名为:");
  15.             string inputFile = @"C:\Users\LeeYunlong\Desktop" + Console.ReadLine() + ".txt";
  16.             Console.WriteLine("加密后的文件名为:");
  17.             string encryptedFile = @"C:\Users\LeeYunlong\Desktop" + Console.ReadLine() + ".txt";
  18.             Console.WriteLine("解密后的文件名为:");
  19.             string outputFile = @"C:\Users\LeeYunlong\Desktop" + Console.ReadLine() + ".txt";
  20.             tripleDES_.Encrypt(inputFile, encryptedFile);
  21.             tripleDES_.Decrypt(encryptedFile, outputFile);

  22.         }
  23.     }
  24. }
复制代码


本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

教学服务系统

GMT+8, 2025-4-30 12:33 , Processed in 0.015416 second(s), 19 queries .

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表