Windows Phone Data Protection
To encrypt the PIN
// Convert the PIN to a byte[].
byte[] PinByte = Encoding.UTF8.GetBytes(TBPin.Text); // Encrypt the PIN by using the Protect() method.
byte[] ProtectedPinByte = ProtectedData.Protect(PinByte, null); // Store the encrypted PIN in isolated storage.
this.WritePinToFile(ProtectedPinByte);
Write PIN to file
// Create a file in the application's isolated storage.
IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream writestream = new IsolatedStorageFileStream(FilePath, System.IO.FileMode.Create, System.IO.FileAccess.Write, file); // Write pinData to the file.
Stream writer = new StreamWriter(writestream).BaseStream;
writer.Write(pinData, 0, pinData.Length);
writer.Close();
writestream.Close();
To decrypt the data
// Retrieve the PIN from isolated storage.
byte[] ProtectedPinByte = this.ReadPinFromFile(); // Decrypt the PIN by using the Unprotect method.
byte[] PinByte = ProtectedData.Unprotect(ProtectedPinByte, null); // Convert the PIN from byte to string and display it in the text box.
TBPin.Text = Encoding.UTF8.GetString(PinByte, 0, PinByte.Length);
Read PIN from file
// Access the file in the application's isolated storage.
IsolatedStorageFile file = IsolatedStorageFile.GetUserStoreForApplication();
IsolatedStorageFileStream readstream = new IsolatedStorageFileStream(FilePath, System.IO.FileMode.Open, FileAccess.Read, file); // Read the PIN from the file.
Stream reader = new StreamReader(readstream).BaseStream;
byte[] pinArray = new byte[reader.Length]; reader.Read(pinArray, 0, pinArray.Length);
reader.Close();
readstream.Close(); return pinArray;
Windows Phone Data Protection的更多相关文章
- ASP.NET Core 数据保护(Data Protection 集群场景)【下】
前言 接[中篇],在有一些场景下,我们需要对 ASP.NET Core 的加密方法进行扩展,来适应我们的需求,这个时候就需要使用到了一些 Core 提供的高级的功能. 本文还列举了在集群场景下,有时候 ...
- ASP.NET Core 数据保护(Data Protection)【上】
前言 上一篇博客记录了如何在 Kestrel 中使用 HTTPS(SSL), 也是我们目前项目中实际使用到的. 数据安全往往是开发人员很容易忽略的一个部分,包括我自己.近两年业内也出现了很多因为安全问 ...
- Asp.net core 学习笔记 ( Data protection )
参考 : http://www.cnblogs.com/xishuai/p/aspnet-5-identity-part-one.html http://cnblogs.com/xishuai/p/a ...
- vSphere Data Protection – a new backup product included with vSphere 5.1
August 27, 2012 By Vladan SEGET This new backup product replaces VMware Data Recovery, which has bee ...
- 实验室报告:VMware vSphere Data Protection
dd Lab Reports VMware vSphere Data Protection Fast, Simple, and Agentless Deduplicated Virtual Machi ...
- ASP.NET Core 数据保护(Data Protection)【中】
前言 上篇主要是对 ASP.NET Core 的 Data Protection 做了一个简单的介绍,本篇主要是介绍一下API及使用方法. API 接口 ASP.NET Core Data Prote ...
- iOS 开启data protection 的方法
我这里说的data protection,指的是设备设置密码后,如果设备锁屏,并且当前解锁需要密码(有时可能因为自己的设定,导致会再几小时后才需要密码),这时应用程序处于加密状态,无法从外部读取.如果 ...
- Data Protection - how to manage expired key?(转载)
问 According to ASP.NET Key Management: Deleting a key is truly destructive behavior, and consequentl ...
- 【VMware vSphere】vSphere Data Protection简介
[前言] 还记得一月份左右的时候,万达这边的服务器突然宕机,导致所有的项目不得不停止不说,还损失掉了很多宝贵的数据.为了防止这种情况再次发生,所以近期研究了vSphere Data Protectio ...
随机推荐
- wp8 入门到精通 启动系统分享照片任务
PhotoChooserTask photoChooserTask = new PhotoChooserTask(); photoChooserTask.Completed += photoChoos ...
- EF中无法使用时间转字符串
场景: 查询条件需要使用到时间类型,且需要特殊格式化,例:ToString("yyyy-MM-dd"):即,在需要使用时间进行like方式处理时: 此时,用如下方式: var q ...
- HTML5——摒弃插件和前端框架的异步文件上传
之前我从来没有体会到HTML5的便利,直到这次需要一个异步上传的功能功能.一开始我以为文件的一些声明必须为HTML5才管用,后来才知道添加了很多以前没有的标签,并可以直接播放视频,音频等.可以不再使用 ...
- C 和 C++ 混合代码 cmath编译出错
最近在网上下载了 Triangle 库,准备在程序中调用来三角化生成网格,但出现了很多错误,如下: 1> triangle.c1>d:\program files\visualstudi ...
- 【转】Struts2解决表单重复提交问题
用户重复提交表单在某些场合将会造成非常严重的后果.例如,在使用信用卡进行在线支付的时候,如果服务器的响应速度太慢,用户有可能会多次点击提交按钮,而这可能导致那张信用卡上的金额被消费了多次.因此,重复提 ...
- Linux将文件拷到u盘
1:终端中获取root后,使用fdisk -l来查看位置 2:挂载u盘:mount /路径 /mnt cd /mnt可进入u盘,ls可查看文件 3:复制:cp /(文件路径) /mnt 4:退出u盘: ...
- jQuery插件开发--(转)
1,开始 可以通过为jQuery.fn增加一个新的函数来编写jQuery插件.属性的名字就是你的插件的名字: jQuery.fn.myPlugin = function(){ //开始写你的代码吧! ...
- 关于初级java面试问题的一些整理 (部分转自他人)
1.面向对象的特征有哪些方面 1.抽象: 抽象就是忽略一个主题中与当前目标无关的那些方面,以便更充分地注意与当前目标有关的方面.抽象并不打算了解全部问题,而只是选择其中的一部分,暂时不用部 ...
- ASP.NET中的GridView自带的编辑更新功能
string ConStr = ConfigurationManager.ConnectionStrings["NorthwindConnectionString"].Connec ...
- 基于netty的微服务架构
基于netty的微服务架构 微服务一篇好文章 http://san-yun.iteye.com/blog/1693759 教程 http://udn.yyuap.com/doc/essential-n ...