windows phone开发之客户端本地简单填充加密解密
2011-12-21 10:46
483 查看
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; } } }
相关文章推荐
- Windows Phone开发之客户端本地简单填充加密解密
- windows phone开发之客户端本地简单填充加密解密
- Jsoup开发简单网站客户端之读取本地html文件
- 与众不同 windows phone (28) - Feature(特性)之手机方向, 本地化, 应用程序的试用体验, 系统主题资源, 本地数据的加密解密
- Java版适用于PHP版3DES加密解密(PHP语言开发的MCRYPT_3DES算法、MCRYPT_MODE_ECB模式、PKCS7填充方式)
- Visual Studio 2017中使用正则修改部分内容 如何使用ILAsm与ILDasm修改.Net exe(dll)文件 C#学习-图解教程(1):格式化数字字符串 小程序开发之图片转Base64(C#、.Net) jquery遍历table为每一个单元格取值及赋值 。net加密解密相关方法 .net关于坐标之间一些简单操作
- 与众不同 windows phone (28) - Feature(特性)之手机方向, 本地化, 应用程序的试用体验, 系统主题资源, 本地数据的加密解密
- iOS开发:base64简单的加密和解密使用
- Java 加密解密简单实现
- 如何利用异或运算进行简单加密解密
- 简单服务端和客户端的开发
- Qt对中文文件的简单加密解密
- iOS开发之Objective-c的AES加密和解密算法的实现
- C++ 简单的文件加密和解密 实例
- 新时尚Windows8开发(9):加密和解密数据
- java开发的一个简单的本地web服务器
- 用NET-SNMP软件包开发简单客户端代理
- thinkphp微信开发(消息加密解密)
- DES 方式:文件加密与解密的简单测试
- Windows Phone 7 简单的饭否客户端