windows phone开发之客户端本地简单填充加密解密
来源:互联网 发布:r语言数据分类 编辑:程序博客网 时间:2024/06/06 08:34
using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Security.Cryptography;
//创建人:vakin 时间:2011-12-15
namespace MicroBlogForWP7.Classes.Util
{
//将输入的字符串转换为字节数组
//然后使用ProtectedData以及预先定义的字节数组进行加密
//加密后得到的也是一个字节数据
//最后使用Convert.ToBase64String得到其对应的字符串
public class Encrypt
{
//预先定义的字节数组如下:
byte[] opt = new byte[] { 1, 2, 4, 8, 16 };
/// <summary>
/// 密码的加密操作
/// </summary>
/// <param name="userpassword">未加密的密码内容</param>
/// <returns></returns>
private string EncryptPwd(string userpassword)
{
byte[] input = System.Text.Encoding.UTF8.GetBytes(userpassword);
string result = Convert.ToBase64String(ProtectedData.Protect(input, opt));
return result;
}
/// <summary>
/// 解密解码。没有加密的情况下返回null
/// </summary>
/// <param name="userpassword">加密后的密码内容</param>
/// <returns></returns>
private string DecryptPwd(string userpassword)
{
if (string.IsNullOrEmpty(userpassword))
{
//没有加密的密码
return null;
}
byte[] output = Convert.FromBase64String(userpassword);
byte[] en = ProtectedData.Unprotect(output, opt);
string result = System.Text.Encoding.UTF8.GetString(en, 0, en.Length);
return result;
}
}
}
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;
using System.Security.Cryptography;
//创建人:vakin 时间:2011-12-15
namespace MicroBlogForWP7.Classes.Util
{
//将输入的字符串转换为字节数组
//然后使用ProtectedData以及预先定义的字节数组进行加密
//加密后得到的也是一个字节数据
//最后使用Convert.ToBase64String得到其对应的字符串
public class Encrypt
{
//预先定义的字节数组如下:
byte[] opt = new byte[] { 1, 2, 4, 8, 16 };
/// <summary>
/// 密码的加密操作
/// </summary>
/// <param name="userpassword">未加密的密码内容</param>
/// <returns></returns>
private string EncryptPwd(string userpassword)
{
byte[] input = System.Text.Encoding.UTF8.GetBytes(userpassword);
string result = Convert.ToBase64String(ProtectedData.Protect(input, opt));
return result;
}
/// <summary>
/// 解密解码。没有加密的情况下返回null
/// </summary>
/// <param name="userpassword">加密后的密码内容</param>
/// <returns></returns>
private string DecryptPwd(string userpassword)
{
if (string.IsNullOrEmpty(userpassword))
{
//没有加密的密码
return null;
}
byte[] output = Convert.FromBase64String(userpassword);
byte[] en = ProtectedData.Unprotect(output, opt);
string result = System.Text.Encoding.UTF8.GetString(en, 0, en.Length);
return result;
}
}
}
- Windows Phone开发之客户端本地简单填充加密解密
- windows phone开发之客户端本地简单填充加密解密
- Windows Phone应用程序中加密解密数据
- [windows phone开发]本地相册
- Windows Phone开发之枚举类型简单应用
- Android开发之加密解密
- Windows Phone开发之DateTime
- 加密解密系列文章之 - ASCII 加密解密(最简单的加密解密) 上
- 加密解密系列文章之 - ASCII 加密解密(最简单的加密解密) 下
- 攻破Windows加密保护之EFS解密
- RSA加密:Windows Phone 公钥加密,Java私钥解密
- 简单搭建Windows Phone 7 开发环境
- ios开发之DES+Base64 加密、解密
- Java开发之java加密解密
- Windows Phone 7 简单的饭否客户端
- Windows Phone开发(48):不可或缺的本地数据库
- windows phone开发学习--本地实现toast通知提醒
- Windows Phone 7(WP7)开发 读取本地资源文件
- SRM 531 DIV 2
- MyEclipse 8.5 ~ 9.0 安装svn插件方法
- VS软件下载
- Android Bitmap 工具类
- linux gcc rpm包安装过程
- windows phone开发之客户端本地简单填充加密解密
- 云测网络:Zaker发布Android版本,适配情况不乐观
- VS配制X64驱动:fatal error LNK1112: module machine type 'x64' conflicts with target machine type 'X86'
- WP7 ZIP 压缩与解压缩
- 计算字串出现关键字次数和所在位置
- HTML页面表单控件的包装类
- 提问的智慧
- Android开发基础篇(1)-----Button
- log4j.properties配置详解