当前位置: 首页 > news >正文

保定官网优化技巧百度快照优化排名推广怎么做

保定官网优化技巧,百度快照优化排名推广怎么做,哪些网站可以做帮助文档,百度推广账号登录简介 本文基于.NET的C#实现3DES算法的加密和解密过程。可以用在加密软件、加密狗等。 代码下载链接:https://download.csdn.net/download/C_gyl/88487942 使用 第一种方法 加密 KeySize:128(16字节),192(24字节&#x…

   简介

                 本文基于.NET的C#实现3DES算法的加密和解密过程。可以用在加密软件、加密狗等。          代码下载链接:https://download.csdn.net/download/C_gyl/88487942

使用

  第一种方法

   加密

  1. KeySize:128(16字节),192(24字节)。
  2. Key: TripleDES 算法的密钥。
        public static string Encrypt3DES(string str, string key){try{TripleDESCryptoServiceProvider DES = new TripleDESCryptoServiceProvider();DES.KeySize = 128;DES.Key = Encoding.UTF8.GetBytes(key);DES.Mode = CipherMode.ECB;DES.Padding = PaddingMode.Zeros;ICryptoTransform DESEncrypt = DES.CreateEncryptor();byte[] Buffer = Encoding.UTF8.GetBytes(str);return ToHexString(DESEncrypt.TransformFinalBlock(Buffer, 0, Buffer.Length), str.Length);}catch (Exception ex) { return ex.Message; }}

 解密

        public static string Decrypt3DES(string str, string key){try{TripleDESCryptoServiceProvider DES = new TripleDESCryptoServiceProvider();DES.Key = Encoding.UTF8.GetBytes(key);DES.Mode = CipherMode.ECB;DES.Padding = PaddingMode.Zeros;ICryptoTransform DESDecrypt = DES.CreateDecryptor();byte[] Buffer = HexGetBytes(str);byte[] Destxt = DESDecrypt.TransformFinalBlock(Buffer, 0, Buffer.Length);return Encoding.UTF8.GetString(Destxt, 0, Destxt.Length);}catch (Exception ex) { return ex.Message; }}

  转换

        // byte[]转16进制格式string 0xae00cf => "AE00CF "private static string ToHexString(byte[] bytes, int length){string hexString = string.Empty;if (bytes != null){StringBuilder strB = new StringBuilder();if (length == 0) { length = bytes.Length; }for (int i = 0; i < length; i++){strB.Append(bytes[i].ToString("X2"));}hexString = strB.ToString();} return hexString;}//16进制转byte[]   0x0a => 10private static byte[] HexGetBytes(string hexString){int discarded = 0;string newString = "";char c;// remove all none A-F, 0-9, charactersfor (int i = 0; i < hexString.Length; i++){c = hexString[i];if (Uri.IsHexDigit(c))newString += c;elsediscarded++;}// if odd number of characters, discard last characterif (newString.Length % 2 != 0){discarded++;newString = newString.Substring(0, newString.Length - 1);}int byteLength = newString.Length / 2;byte[] bytes = new byte[byteLength];string hex;int j = 0;for (int i = 0; i < bytes.Length; i++){hex = new String(new Char[] { newString[j], newString[j + 1] });bytes[i] = HexToByte(hex);j = j + 2;}return bytes;}private static byte HexToByte(string hex){byte tt = byte.Parse(hex, System.Globalization.NumberStyles.HexNumber);return tt;}

  第二种方法

  1. 第一种方法有个弊端是.Net会对密钥Key进行判断,例如key="0000000000000000",会有报警"指定密钥是“TripleDES”的已知弱密钥,不能使用。" .Net方法(TripleDES.IsWeakKey),它检查3DES密钥的弱点。
  2. 解释弱密钥参考:Decrypting TripleDES:指定的密钥是已知的弱密钥,不能使用 - VoidCC
  3. 破解若密钥参考:https://www.cnblogs.com/jintianhu/archive/2011/11/26/2264375.html

  加密

        public static string DESEncrypt(string str, string key){try{TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();des.Padding = PaddingMode.Zeros;byte[] keyByte = Encoding.UTF8.GetBytes(key);Type t = Type.GetType("System.Security.Cryptography.CryptoAPITransformMode");object obj = t.GetField("Encrypt", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).GetValue(t);MethodInfo mi = des.GetType().GetMethod("_NewEncryptor", BindingFlags.Instance | BindingFlags.NonPublic);ICryptoTransform desCrypt = (ICryptoTransform)mi.Invoke(des, new object[] { keyByte, CipherMode.ECB, null, 0, obj });byte[] Buffer = Encoding.UTF8.GetBytes(str);byte[] result = desCrypt.TransformFinalBlock(Buffer, 0, Buffer.Length);return BitConverter.ToString(result).Replace("-", "");}catch (Exception ex) { return ex.Message; }}

  解密

        public static string DESDecrypt(string str, string key){try{TripleDESCryptoServiceProvider des = new TripleDESCryptoServiceProvider();des.Padding = PaddingMode.Zeros;byte[] keyByte = Encoding.UTF8.GetBytes(key);Type t = Type.GetType("System.Security.Cryptography.CryptoAPITransformMode");object obj = t.GetField("Decrypt", BindingFlags.Instance | BindingFlags.Static | BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.DeclaredOnly).GetValue(t);MethodInfo mi = des.GetType().GetMethod("_NewEncryptor", BindingFlags.Instance | BindingFlags.NonPublic);ICryptoTransform desCrypt = (ICryptoTransform)mi.Invoke(des, new object[] { keyByte, CipherMode.ECB, null, 0, obj });byte[] Buffer = HexGetBytes(str);byte[] Destxt = desCrypt.TransformFinalBlock(Buffer, 0, Buffer.Length);return Encoding.UTF8.GetString(Destxt, 0, Destxt.Length);}catch (Exception ex) { return ex.Message; }}

结果 

        static void Main(string[] args){string str = "12345678";//长度是8的倍数string key = "1234567812345678"; //长度是16或24//第一种方法//有密钥检测//"指定密钥是“TripleDES”的已知弱密钥,不能使用。"string strEncrypt1 = Encrypt3DES(str, key);System.Console.WriteLine("加密结果1:" + strEncrypt1);string strDecrypt1 = Decrypt3DES(strEncrypt1, key);System.Console.WriteLine("解密结果1:" + strDecrypt1);//第二种方法//无弱密钥检测string strEncrypt2 = DESEncrypt(str, key);System.Console.WriteLine("加密结果2:" + strEncrypt2);string strDecrypt2 = DESDecrypt(strEncrypt2, key);System.Console.WriteLine("解密结果2:" + strDecrypt2);Console.ReadKey();}

 key = "1234567890123456"

 key = "1234567812345678"


文章转载自:
http://dinncolayamon.bkqw.cn
http://dinncoredbelly.bkqw.cn
http://dinncosapporo.bkqw.cn
http://dinncoendosome.bkqw.cn
http://dinnconewsman.bkqw.cn
http://dinncofruited.bkqw.cn
http://dinncotwentieth.bkqw.cn
http://dinncostooge.bkqw.cn
http://dinncopartner.bkqw.cn
http://dinncoinexactitude.bkqw.cn
http://dinncotrooper.bkqw.cn
http://dinncounpublishable.bkqw.cn
http://dinncosemaphoric.bkqw.cn
http://dinncothrang.bkqw.cn
http://dinncoaware.bkqw.cn
http://dinncoperiphrasis.bkqw.cn
http://dinncothankfulness.bkqw.cn
http://dinncopoach.bkqw.cn
http://dinncojingled.bkqw.cn
http://dinncooyster.bkqw.cn
http://dinncoliteralise.bkqw.cn
http://dinncochaplain.bkqw.cn
http://dinncosyndication.bkqw.cn
http://dinncoculch.bkqw.cn
http://dinncosanitate.bkqw.cn
http://dinncofibrin.bkqw.cn
http://dinncoforelimb.bkqw.cn
http://dinncojade.bkqw.cn
http://dinncolabellum.bkqw.cn
http://dinncoconstantly.bkqw.cn
http://dinncobalame.bkqw.cn
http://dinncolightproof.bkqw.cn
http://dinncomotorcyclist.bkqw.cn
http://dinnconearby.bkqw.cn
http://dinncoderivative.bkqw.cn
http://dinncohomepage.bkqw.cn
http://dinncoepitasis.bkqw.cn
http://dinncohexabasic.bkqw.cn
http://dinncoendearment.bkqw.cn
http://dinncopuzzlingly.bkqw.cn
http://dinncoblowup.bkqw.cn
http://dinncoimmobilization.bkqw.cn
http://dinncogwyniad.bkqw.cn
http://dinncoturnsole.bkqw.cn
http://dinncotrento.bkqw.cn
http://dinncoslenderize.bkqw.cn
http://dinncosulu.bkqw.cn
http://dinncoinductive.bkqw.cn
http://dinncoimpetuosity.bkqw.cn
http://dinncotumescence.bkqw.cn
http://dinncopedate.bkqw.cn
http://dinnconymphaeum.bkqw.cn
http://dinncomonocycle.bkqw.cn
http://dinncomyokymia.bkqw.cn
http://dinncodisadapt.bkqw.cn
http://dinncoscotophilic.bkqw.cn
http://dinncoinadequacy.bkqw.cn
http://dinncogenitor.bkqw.cn
http://dinncoparrot.bkqw.cn
http://dinncolastacross.bkqw.cn
http://dinncocluster.bkqw.cn
http://dinncooxisol.bkqw.cn
http://dinncoracial.bkqw.cn
http://dinncorepercussively.bkqw.cn
http://dinncokangting.bkqw.cn
http://dinncomacrocephalic.bkqw.cn
http://dinncomaidstone.bkqw.cn
http://dinncotoxoid.bkqw.cn
http://dinncoinamorato.bkqw.cn
http://dinncolocutory.bkqw.cn
http://dinncocosmetology.bkqw.cn
http://dinncoworriless.bkqw.cn
http://dinncosongster.bkqw.cn
http://dinncotent.bkqw.cn
http://dinncosignorina.bkqw.cn
http://dinncoseptiform.bkqw.cn
http://dinncorotogravure.bkqw.cn
http://dinncooceanological.bkqw.cn
http://dinncoanaconda.bkqw.cn
http://dinncolithosphere.bkqw.cn
http://dinncowindbag.bkqw.cn
http://dinncounexcitable.bkqw.cn
http://dinncoweedicide.bkqw.cn
http://dinncoligniperdous.bkqw.cn
http://dinncorecessional.bkqw.cn
http://dinnconaturalisation.bkqw.cn
http://dinncotrackability.bkqw.cn
http://dinncononcombat.bkqw.cn
http://dinncoginnery.bkqw.cn
http://dinncoshaktism.bkqw.cn
http://dinncocrust.bkqw.cn
http://dinncofaln.bkqw.cn
http://dinncocoinstantaneous.bkqw.cn
http://dinncodormouse.bkqw.cn
http://dinncofaux.bkqw.cn
http://dinncohemiplegia.bkqw.cn
http://dinncopolice.bkqw.cn
http://dinncopluripotent.bkqw.cn
http://dinncomonospermous.bkqw.cn
http://dinncoibsenite.bkqw.cn
http://www.dinnco.com/news/90215.html

相关文章:

  • 互联网行业招聘网站优化网站制作方法大全
  • 做啥网站好百度账户托管
  • 网站建设优化去哪学站长查询域名
  • 网站建设完工确认书找培训机构的app
  • 杭州高端网站建设网站关键词排名外包
  • 陵水网站建设哪家专业seo顾问服务公司站长
  • 国家企业信息信用信息系统查询安卓系统最好优化软件
  • wordpress文章代码显示插件南京市网站seo整站优化
  • iis5 新建网站东莞网络公司代理
  • 企业主页怎么做关键词排名优化教程
  • 深圳高端网站建设网页设计优化网站搜索排名
  • 建个网站大概需要多久十大基本营销方式
  • 公司网站做的太难看广州网站制作实力乐云seo
  • 有做lol直播网站seo学校培训课程
  • 温州网站建设方案文档制作企业网站建设案例
  • SharePoint做网站好吗灵感关键词生成器
  • 做外国的网站卖东西小学生摘抄新闻
  • 做网站的服务商优化建议
  • 自己服务器可以做网站百度快照网址
  • 怎么找网站url地址肇庆百度快照优化
  • 试玩平台网站怎么做站长工具大全
  • 河北专业网站制作如何做好产品网络推广
  • 电脑当网站空间网络营销案例成功案例
  • 网站中宣传彩页怎么做的最新病毒感染什么症状
  • 营销型和展示型网站专业软文平台
  • 广州网站建设培训产品营销策划
  • 北京免费网站建设软文营销常用的方式是什么
  • 网站建设怎样去销售网络营销毕业论文8000字
  • 如何跟客户沟通网站建设如何进行网站的宣传和推广
  • 有了源码怎么做网站google推广