C# 加密-RSA
RSA
属不对称加密,使用一个公钥一个私钥,公钥可以公开用以加密,私钥严格保密用于解密,RSA 适合于数据量不大的加密,比如加密对称加密的密钥。
RSACryptoServiceProvider
的名称空间是:
System.Security.Cryptography
RSACryptoServiceProvider rsaSend = new RSACryptoServiceProvider();
string plaintext = "明文"; //明文
byte[] ciphertext = rsaSend.Encrypt(System.Text.Encoding.UTF8.GetBytes(plaintext), false); //加密后
lbl.Text = Convert.ToBase64String(ciphertext); //显示加密后的,为了显示不可见字符,使用的是 Base64 编码。
使用 RSACryptoServiceProvider() 创建 RSACryptoServiceProvider 实例时,自动产生密钥。
相关文档:
Eval("")和Bind("") 这两种一个单向绑定,一个双向绑定,bind是双向绑定,但需数据源支持
ASP.NET 2.0改善了模板中的数据绑定操作,把v1.x中的数据绑定语法DataBinder.Eval(Container.DataItem, fieldname)简化为Eval(fieldname)。Eval方法与DataBinder.Eval一样可以接受一个可选的格式化字符串参 ......
一、C#预处理器指令入门 #define NET11 //NET11,NET20,(必须放在文件第一行)
using System;
//… …
//… …
//… …
string sBeepType = s.Replace(sKey,"");
#if NET20
int.TryParse(sBeepType,out beepType); //在.net 2.0中才有的方法
#endif
#if ......
using System.Windows.Forms;
using SAPFunctionsOCX;
using SAPLogonCtrl;
using SAPTableFactoryCtrl;
namespace SAPFunction
{
public partial class Form1 : Form
{
public Form1()
  ......
最近着实忙了一阵子,学习了好多东东都没时间整理,呵呵,总算是要放假了,可以好好归纳归纳了。
设计模式的学习是一个任重而道远的过程了,^_^,要好好总结,总结的目的是让自己好好记住,记住的目的是便于理解,而理解的最终目的是应用,O(∩_∩)O~ 而设计模式也往往是应用的一种重构,循环往复,生生不息啊... .. ......
在 ASP.NET 中可以非常方便地执行 MD5
或 SHA1 加密。
<%@ Import Namespace="System.Web.Security" %>
FormsAuthentication.HashPasswordForStoringInConfigFile
只需要两步,第一步引入名称空间
(该名称空间也可以省略引用),第二步执行加密函数。
FormsAuthentication.HashPasswordForStoringI ......