项目输出目录(bin/debug|release)中经常是这个样子: [crayon-686757de4bcd […]
Python爬虫:Xpath语法笔记
一、选取节点 常用的路劲表达式: 表达式 描述 实例 nodename 选取nodename节点的所有子节点 […]
常用字符串加密解密方法
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
using System; using System.Collections.Generic; using System.IO; using System.Linq; using System.Security.Cryptography; using System.Text; using System.Text.RegularExpressions; using System.Web.Security; namespace HuaTong.General.Utility { /// <summary> /// 加密工具类 /// </summary> public class EncryptHelper { //默认密钥 private static string AESKey = "[45/*YUIdse..e;]"; private static string DESKey = "[&HdN72]"; /// <summary> /// AES加密 /// </summary> public static string AESEncrypt(string value, string _aeskey = null) { if (string.IsNullOrEmpty(_aeskey)) { _aeskey = AESKey; } byte[] keyArray = Encoding.UTF8.GetBytes(_aeskey); byte[] toEncryptArray = Encoding.UTF8.GetBytes(value); RijndaelManaged rDel = new RijndaelManaged(); rDel.Key = keyArray; rDel.Mode = CipherMode.ECB; rDel.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = rDel.CreateEncryptor(); byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); return Convert.ToBase64String(resultArray, 0, resultArray.Length); } /// <summary> /// AES解密 /// </summary> public static string AESDecrypt(string value, string _aeskey = null) { try { if (string.IsNullOrEmpty(_aeskey)) { _aeskey = AESKey; } byte[] keyArray = Encoding.UTF8.GetBytes(_aeskey); byte[] toEncryptArray = Convert.FromBase64String(value); RijndaelManaged rDel = new RijndaelManaged(); rDel.Key = keyArray; rDel.Mode = CipherMode.ECB; rDel.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = rDel.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); return Encoding.UTF8.GetString(resultArray); } catch { return string.Empty; } } /// <summary> /// DES加密 /// </summary> public static string DESEncrypt(string value, string _deskey = null) { if (string.IsNullOrEmpty(_deskey)) { _deskey = DESKey; } byte[] keyArray = Encoding.UTF8.GetBytes(_deskey); byte[] toEncryptArray = Encoding.UTF8.GetBytes(value); DESCryptoServiceProvider rDel = new DESCryptoServiceProvider(); rDel.Key = keyArray; rDel.Mode = CipherMode.ECB; rDel.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = rDel.CreateEncryptor(); byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); return Convert.ToBase64String(resultArray, 0, resultArray.Length); } /// <summary> /// DES解密 /// </summary> public static string DESDecrypt(string value, string _deskey = null) { try { if (string.IsNullOrEmpty(_deskey)) { _deskey = DESKey; } byte[] keyArray = Encoding.UTF8.GetBytes(_deskey); byte[] toEncryptArray = Convert.FromBase64String(value); DESCryptoServiceProvider rDel = new DESCryptoServiceProvider(); rDel.Key = keyArray; rDel.Mode = CipherMode.ECB; rDel.Padding = PaddingMode.PKCS7; ICryptoTransform cTransform = rDel.CreateDecryptor(); byte[] resultArray = cTransform.TransformFinalBlock(toEncryptArray, 0, toEncryptArray.Length); return Encoding.UTF8.GetString(resultArray); } catch { return string.Empty; } } public static string MD5(string value) { byte[] result = Encoding.UTF8.GetBytes(value); MD5 md5 = new MD5CryptoServiceProvider(); byte[] output = md5.ComputeHash(result); return BitConverter.ToString(output).Replace("-", ""); } public static string HMACMD5(string value, string hmacKey) { HMACSHA1 hmacsha1 = new HMACSHA1(Encoding.UTF8.GetBytes(hmacKey)); byte[] result = System.Text.Encoding.UTF8.GetBytes(value); byte[] output = hmacsha1.ComputeHash(result); return BitConverter.ToString(output).Replace("-", ""); } /// <summary> /// base64编码 /// </summary> /// <returns></returns> public static string Base64Encode(string value) { string result = Convert.ToBase64String(Encoding.Default.GetBytes(value)); return result; } /// <summary> /// base64解码 /// </summary> /// <returns></returns> public static string Base64Decode(string value) { string result = Encoding.Default.GetString(Convert.FromBase64String(value)); return result; } } } |
升级到Flex 4.5 Air 2.6
So if you’re upgrading to Flex SDK 4.5 and Air 2.6 Adob […]
Silverlight Modularity with MEF Behavior Change – exception
Description After upgrading my project to the latest re […]
Visual Studio 2008提高工作效率的小技巧
时间往往在不经意间就浪费掉了,比如我们在寻找上一个光标位置的时候,好好学习并利用下面的技巧,会提高工作效率,减 […]
c# 枚举 enum
从长远来看,创建枚举可以节省大量的时间,减少许多麻烦。使用枚举比使用无格式的整数至少有如下三个优势: ●??? […]
SQL2005 SQL2008 远程连接配置方法
SQL2005: 打开SQL2005的配置工具–>SQL Server 2005外围 […]
检索 COM 类工厂中 CLSID 为 {000209FF-0000-0000-C000-000000000046} 的组件时失败
Application当程序运行到这句时出现下面的错误:检索 COM 类工厂中 CLSID 为 {000209 […]
Symbol Mobility Developer Kit v1.7 for .NET
这个下载不好找,记录一下 版本:1.07.03 SMDK for .NET provides all of t […]
Flex学习笔记
1.弹出新窗口 Flex通过PopUpManager类来实现弹出新窗口: 先设置好要弹出窗口的页面,然后在主窗 […]
Flex页面跳转的方法
FLEX和JSP不一样,没有所谓的这个页面跳转到另外的一个页面。一般都是用ViewStack进行页面切换,其他 […]
Image组件怎么才能非等比例拉伸图片
设置Image组件的属性 maintainAspectRatio=”false”
如何强制Flex控件显示手型光标
有时候需要强制某个控件,比如标签(Label)强制显示手型光标(hand cursor),一般情况下可以使用u […]
Microsoft Visual Studio如何重新生成designer.cs
方法很简单 1. 删除 .designer.cs 2. 在 Solution Explorer 中,对应的页面 […]
C#操作word
要使用C#操作word,首先要添加引用: 1、添加引用->COM->Microsoft Word […]
Visual Basic、C# 和 C++ 的数据类型比较
下表列出了 .NET Framework 支持的一些值类型,简要描述了每个类型,并指示 Visual Basi […]
c# 数据集表增删查
using System; using System.Data; using System.Data.SqlC […]
VC6 Symbian开发环境配置
1 安装SDK及VC Nokia根据手机的屏幕大小和价格高低把手机分成了多个系列,现在使用的系列有:Serie […]
c# CheckBox 全部选择与取消选择
1 2 3 4 5 6 7 8 9 |
protected void CheckBoxAll_CheckedChanged(object sender, EventArgs e) { foreach (GridViewRow gvr in GridView1.Rows) { CheckBox cbox = (CheckBox)gvr.FindControl("CheckAll"); cbox.Checked = this.CheckBoxAll.Checked; this.CheckBoxAll.Text = this.CheckBoxAll.Checked ? "取消选择" : "全部选择"; } } |
WPF 深入研究 之 Control 控件
这一章介绍Control 控件。 本章共计51个示例,全都在VS2008下.NET3.5测试通过,点击这里下载 […]
Popup 控件
IsOpen:一个布尔值,指示 Popup 控件是否已经显示 StaysOpen:一个布尔值,指示在 Popu […]
Visual Studio 2008 如何设定 XBAP 成为 Full Trust Application
<a href=”http://msdn2.microsoft.com/en-us/libr […]
线性渐变LinearGradientBrush和GradientStop类
LinearGradientBrush指的是一个线性的坡度类,用它和GradientStop类可以为一个矩形区 […]
WPF中的Style
在WPF中我们可以使用Style来设置控件的某些属性值,并使该设置影响到指定范围内的所有该类控件或影响指定的某 […]