zoukankan
html css js c++ java
windows phone开发之客户端本地简单填充加密解密
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; } } }
查看全文
相关阅读:
Redis "MISCONF Redis is configured to save RDB snapshots, but is currently not able to persist on disk"问题的解决
素描
python 标准库
Python内置函数filter, map, reduce
Python的lambda表达式
python中super关键字的用法
python一个注意的地方
python中self,cls
python中的实例方法、静态方法、类方法、类变量和实例变量
python模块及包的导入
原文地址:https://www.cnblogs.com/javawebsoa/p/2458108.html
最新文章
appium+python自动化64-使用Uiautomator2执行driver.keyevent()方法报错解决
appium+python自动化63-使用Uiautomator2报错问题解决
appium+python自动化62-webview元素click失效问题解决
偏序最小二乘回归
模型选择、特征选择及贝叶斯正则化
再谈主成分分析
主成分分析、因子分析、聚类分析的比较与应用
Word中向左缩进
刘波对大一的寄语
做科研的两条黄金法则-何毓琦
热门文章
Word中设置三栏式表格
Word中正文两栏表格通栏排版
Word中公式从单栏排版变为双栏排版后公式和编号错开了
python格式化输出
git merge
Python使用UUID库生成唯一ID
python 模块zlib 压缩与解压
python计算非内置数据类型占用内存
解决git clone时报错:The requested URL returned error: 401 Unauthorized while accessing
postgresql 死锁处理
Copyright © 2011-2022 走看看