91av视频/亚洲h视频/操亚洲美女/外国一级黄色毛片 - 国产三级三级三级三级

  • 大小: 16KB
    文件類型: .rar
    金幣: 2
    下載: 0 次
    發(fā)布日期: 2021-05-17
  • 語言: C#
  • 標(biāo)簽: C#??DES??ECB??加密解密??源碼??

資源簡介

C#DES標(biāo)準(zhǔn)ECB加密解密示例源碼,根據(jù)標(biāo)準(zhǔn)的C改的源碼,與網(wǎng)上所搜索到的完全不一樣,可以支持中文為密鑰的加密,也可以支持為中文字符串的加密,如,密鑰為:替天行道,明文為:來自替天行道的C#DES標(biāo)準(zhǔn)ECB加密解密示例源碼,加密后為:16505C9E77FA5959E9F6F6FEB031A9D35DEF8F38134311E850A0081B1A6205EBCCBFFABE291EC7D2A462B2A7E6AA1734B741867CDF093408,解密也是一樣的。值得參考

資源截圖

代碼片段和文件信息

using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Data;
using?System.Drawing;
using?System.Linq;
using?System.Text;
using?System.Threading.Tasks;
using?System.Windows.Forms;
using?System.IO;
using?System.Security.Cryptography;
using?System.Globalization;



namespace?WindowsFormsApplication1
{
???
????public?partial?class?Form1?:?Form
????{
??????
???????public?static?string?EncryptString(string?sInputString?string?sKey)
???????{
???????????try
???????????{
???????????????byte[]?data?=?System.Text.Encoding.Default.GetBytes(sInputString);
???????????????DESCryptoServiceProvider?DES?=?new?DESCryptoServiceProvider();
???????????????DES.Key?=?System.Text.Encoding.Default.GetBytes(sKey);
???????????????DES.IV?=?System.Text.Encoding.Default.GetBytes(sKey);
???????????????DES.Padding?=?PaddingMode.Zeros;
???????????????DES.Mode?=?CipherMode.ECB;
???????????????ICryptoTransform?desencrypt?=?DES.CreateEncryptor();
???????????????byte[]?result?=?desencrypt.TransformFinalBlock(data?0?data.Length);
???????????????return?BitConverter.ToString(result).Replace(“-“?string.Empty);
?????????????//??return?BitConverter.ToString(result);
???????????}
???????????catch?{?}

???????????return?“轉(zhuǎn)換出錯!密鑰必須為8位可用4個中文字符代替!“;
???????}
???????public?static?string?DecryptString(string?sInputString?string?sKey)
???????{
???????????try
???????????{
???????????????byte[]?data?=?new?byte[sInputString.Length?/?2];
???????????????for?(int?i?=?0;?i????????????????{
???????????????????data[i]?=?byte.Parse(sInputString.Substring(i?*?2?2)?Numberstyles.HexNumber);
???????????????}???????????
???????????????DESCryptoServiceProvider?DES?=?new?DESCryptoServiceProvider();
???????????????DES.Key?=?System.Text.Encoding.Default.GetBytes(sKey);
???????????????DES.IV?=?System.Text.Encoding.Default.GetBytes(sKey);
???????????????DES.Padding?=?PaddingMode.Zeros;
???????????????DES.Mode?=?CipherMode.ECB;
???????????????ICryptoTransform?desencrypt?=?DES.CreateDecryptor();
???????????????byte[]?result?=?desencrypt.TransformFinalBlock(data?0?data.Length);
??????????????//?return?Encoding.UTF8.GetString(result);
???????????????return??System.Text.Encoding.Default.GetString(result);?
???????????}
???????????catch?{?}
???????????return?“解密出錯!“;
???????}
????????public?Form1()
????????{
????????????InitializeComponent();

????????}
???????
????????private?void?button1_Click(object?sender?EventArgs?e)
????????{

????????????textBox3.Text?=?EncryptString(textBox2.Text?textBox1.Text);
????????}

????????private?void?button2_Click(object?sender?EventArgs?e)
????????{
????????????textBox2.Text?=?DecryptString(textBox3.Text?textBox1.Text);
????????}
????}
}

?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----

?????文件??????11776??2015-09-29?15:20??C#DES標(biāo)準(zhǔn)ECB加密解密\DES.exe

?????文件????????187??2015-09-28?16:11??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1\App.config

?????文件???????2854??2015-09-29?15:20??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1\Form1.cs

?????文件???????6303??2015-09-29?15:20??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1\Form1.Designer.cs

?????文件???????5817??2015-09-29?15:20??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1\Form1.resx

?????文件????????536??2015-09-28?16:11??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1\Program.cs

?????文件???????3828??2015-09-29?14:21??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1\WindowsFormsApplication1.csproj

?????文件???????1041??2015-09-28?16:11??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1.sln

????..A..H.?????39936??2015-09-29?15:23??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1.v12.suo

?????目錄??????????0??2015-09-29?15:23??C#DES標(biāo)準(zhǔn)ECB加密解密\WindowsFormsApplication1

?????目錄??????????0??2015-09-29?15:23??C#DES標(biāo)準(zhǔn)ECB加密解密

-----------?---------??----------?-----??----

????????????????72278????????????????????11


評論

共有 條評論