using System;
using System.Text;
using System.Security.Cryptography;
using System.IO; namespace DESPwd
{
public class DESUtil
{
static DESCryptoServiceProvider des = new DESCryptoServiceProvider(); public static DESCryptoServiceProvider DES
{
get { return des; }
}
const string EncryptionKey = "诺丽科技";
const string EncryptionIV = "kell";
public static string Encoder(string input)
{
byte[] SourceData = Encoding.Unicode.GetBytes(input);
byte[] returnData = null;
try
{
des.Key = ASCIIEncoding.Unicode.GetBytes(EncryptionKey);
des.IV = ASCIIEncoding.Unicode.GetBytes(EncryptionIV);
MemoryStream ms = new MemoryStream();
CryptoStream cs = new CryptoStream(ms, des.CreateEncryptor(), CryptoStreamMode.Write);
cs.Write(SourceData, , SourceData.Length);
cs.FlushFinalBlock();
returnData = ms.ToArray();
}
catch (Exception ex)
{
throw ex;
}
return Encoding.Unicode.GetString(returnData);
}
public static string Decoder(string input)
{
byte[] SourceData = Encoding.Unicode.GetBytes(input);
byte[] returnData = null;
try
{
DESCryptoServiceProvider desProvider = new DESCryptoServiceProvider();
desProvider.Key = Encoding.Unicode.GetBytes(EncryptionKey);
desProvider.IV = Encoding.Unicode.GetBytes(EncryptionIV);
MemoryStream ms = new MemoryStream();
ICryptoTransform encrypto = desProvider.CreateDecryptor();
CryptoStream cs = new CryptoStream(ms, encrypto, CryptoStreamMode.Write);
cs.Write(SourceData, , SourceData.Length);
cs.FlushFinalBlock();
returnData = ms.ToArray();
}
catch (Exception ex)
{
throw ex;
}
return Encoding.Unicode.GetString(returnData);
}
}
}
using System;
using System.Windows.Forms; namespace DESPwd
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
} private void button10_Click(object sender, EventArgs e)
{
textBox9.Text = DESUtil.Encoder(textBox8.Text);
} private void button11_Click(object sender, EventArgs e)
{
textBox11.Text = DESUtil.Decoder(textBox9.Text);
}
}
}

最新文章

  1. 云计算之路-阿里云上:“黑色1秒”最新线索——w3tp与w3dt
  2. localForage——轻松实现 Web 离线存储(转)
  3. 为jQuery-easyui的tab组件添加右键菜单功能
  4. 44. Decode Ways && Gray Code
  5. 【POJ 1416】Shredding Company
  6. hadoop源码阅读
  7. Android ImageView 详述
  8. 09_platform-tools简介&常见adb指令
  9. 浅析CDN安全
  10. 针对SharePointFarm场时安装部署OWA的步骤
  11. 总结的一些封装好的javascript函数
  12. jQuery中的.live()与die()
  13. GDI+ 填充背景时,非常多时候不起作用,GDI、GDI+配合运用
  14. sockaddr_u详解
  15. 腾讯2017年暑期实习生编程题【算法基础-字符移位】(C++,Python)
  16. 前端生成pdf
  17. How HashMap works in java 2
  18. 二进制安装mysql 5.6
  19. 编译和运行java文件 找不到或无法加载主类
  20. MongoDB登录验证及用户管理

热门文章

  1. USRP B210 更改A通道或B通道
  2. p2456二进制方程 题解
  3. 为什么程序员一定要会用Google和Stack Overflow?
  4. slices = [dicom.read_file(path + '/' + s) for s in os.listdir(path)] FileNotFoundError: [WinError 3] 系统找不到指定的路径。
  5. 使用OmniDiskSweeper清理MAC
  6. Wuss Weapp 微信小程序 UI 组件库
  7. PyQt打包可执行文件
  8. 题解 矩阵 matrix
  9. 【C#-程序时间计数器】如何计算某些步骤/过程耗时多少?
  10. fegin熔断autowired失败