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 ...
随机推荐
- PHP利用jquery生成各种验证码和Ajax验证
PHP生成验证码图片 PHP生成验证码的原理:使用PHP的GD库,生成一张带验证码的图片,并将验证码保存在Session中.PHP 生成验证码的大致流程有: .产生一张png的图片: .为图片设置背景 ...
- SOA 架构中的ESB是更好的应用于异构系统集成整合还是用于统一服务调用/基础服务实施
一.讨论主题与观点 写一篇文章.发现一次自觉得有意思的SOA架构方面的讨论,源于昨天AgileEAS.NET SOA 平台群(113723486)里几个群友的一次关于ESB的一次讨论. 大家的讨论观点 ...
- 【leetcode】Sqrt(x)
题目描述: Implement int sqrt(int x). Compute and return the square root of x. 实现开根号,并且返回整数值(这个很重要,不是整数的话 ...
- Ubuntu下配置samba实现文件夹共享
转自:http://www.cnblogs.com/phinecos/archive/2009/06/06/1497717.html 一. samba的安装: sudo apt-get insall ...
- .deb文件打包
最近因项目需要,需要把文件夹打包为.deb格式的包,幸亏一位朋友帮忙指导了我一个晚上,才得以完成,这里再次对他表示感谢. 整理打包流程如下: 请先参考此博客内容,了解deb文件打包 如何制作Deb包和 ...
- 程序员应该是使用git
我来梳理下我想用git做的事情应该拥有那些功能: 本地的git命令以及图形界面,好让我在没有联网的时候创建git版本控制记录历史功能 一个github账号,好让我可以把本地的git仓库同步到那里 功能 ...
- sql 数字转人民币大写函数(两种方法)
,)) returns @rmb table( 亿 ) ,仟万 ) ,佰万 ) ,拾万 ) ,万 ) ,仟 ) ,佰 ) ,拾 ) ,元 ) ,角 ) ,分 )) as begin insert in ...
- 用js 向h5 中的table 动态添加数据 (简单实现)
//向 表格传值 function setTextareaValue(items,pp){ console.log(" 进入函数 items=="+items); var tb = ...
- POJ 3415 后缀数组
题目链接:http://poj.org/problem?id=3415 题意:给定2个串[A串和B串],求两个串公共子串长度大于等于k的个数. 思路:首先是两个字符串的问题.所以想用一个'#'把两个字 ...
- js不间断平滑地自动向上滚动
<html> <head> <title>scroll up auto smooth</title> <style> *{ margin: ...