关于Data Protection API (非托管加密类)的练习

来源:互联网 发布:ck内裤价格知乎 编辑:程序博客网 时间:2024/05/17 22:34

Data Protection API 简称 DPAPI 是非托管 集成于Windows系统中的一个数据保护类,下面是ProtectedData类和ProtectedMemory类的练习..

 

//Get User Input Data's

String Input=Console.ReadLine();

 

//Change Input Data  to Bytes

Byte[] DataToEncryp=encoding.UTF8.GetBytes(Input);

 

//Defination The Keys

Byte[] Keys=new Byte[]{0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x40};

 

//Implementation of the Cryptographic Service

Byte[] EncryptData=ProtectedData.Protecd(DataToEncryp,Keys,DataProtectionScope.CurrentUser);

 

//OutPut Encrypted Content

Console.WriteLine(Convert.ToBase64String(EncryptData));

 

下面时ProtectedMemory的实例代码

 

原创粉丝点击