C# 加密-TripleDES
TripleDES
属对称加密,对称加密在加密和解密时都使用相同的密钥,速度快。
TripleDESCryptoServiceProvider 的名称空间是:
System.Security.Cryptography
byte[] plaintextBuffer = System.Text.Encoding.UTF8.GetBytes("明文");
//加密
TripleDESCryptoServiceProvider tripleDES = new TripleDESCryptoServiceProvider();
ICryptoTransform transform = tripleDES.CreateEncryptor();
byte[] cipherTextBuffer = transform.TransformFinalBlock(plaintextBuffer, 0, plaintextBuffer.Length);
lbl.Text = Convert.ToBase64String(cipherTextBuffer) + "<br />";
transform.Dispose();
//解密
TripleDESCryptoServiceProvider tripleDES2 = new TripleDESCryptoServiceProvider();
ICryptoTransform transform2 = tripleDES2.CreateDecryptor(tripleDES.Key, tripleDES.IV);
byte[] decryption = transform2.TransformFinalBlock(cipherTextBuffer, 0, cipherTextBuffer.Length);
lbl.Text += System.Text.Encoding.UTF8.GetString(decryption) + "<br />";
transform2.Dispose();
解密时,使用加密的 Key 和 IV。
相关文档:
c#中基类(父类)中的某方法若想在派生类(子类)中被重写(override),必须将基类中的方法定义为virtual,即虚函数。
若派生类将方法修饰为new,即有意隐藏基类中的方法。
下面看一组代码:
public class Father
{
public void hand()
{
Console.WriteLine("Father.hand");
}
}
......
一、C#预处理器指令入门 #define NET11 //NET11,NET20,(必须放在文件第一行)
using System;
//… …
//… …
//… …
string sBeepType = s.Replace(sKey,"");
#if NET20
int.TryParse(sBeepType,out beepType); //在.net 2.0中才有的方法
#endif
#if ......
styleObj用于设置图层的符号。它在classObj中定义,一般于symbolObj一起使用。通过设置styleObj,可以产生千变万化,丰富多彩的地图。
一个简单的styleObj示例:
CLASS
NAME "Primary Roads"
STYLE
SYMBOL "circle"
COLOR 178 114 1
SIZE 15
END #style1
STYLE
SYMBOL "circle"
COLOR 254 161 0
SIZE 7
END #s ......
最近着实忙了一阵子,学习了好多东东都没时间整理,呵呵,总算是要放假了,可以好好归纳归纳了。
设计模式的学习是一个任重而道远的过程了,^_^,要好好总结,总结的目的是让自己好好记住,记住的目的是便于理解,而理解的最终目的是应用,O(∩_∩)O~ 而设计模式也往往是应用的一种重构,循环往复,生生不息啊... .. ......
在 ASP.NET 中可以非常方便地执行 MD5
或 SHA1 加密。
<%@ Import Namespace="System.Web.Security" %>
FormsAuthentication.HashPasswordForStoringInConfigFile
只需要两步,第一步引入名称空间
(该名称空间也可以省略引用),第二步执行加密函数。
FormsAuthentication.HashPasswordForStoringI ......