Windows Phone 8.1 is Here

Windows Phone 8.1

For users of the Nokia Lumia 1520 on AT&T, the Microsoft Windows Phone 8.1 mobile operating system update is available for immediate download.

The smartphone built from the ground-up to address the security and management needs of every enterprise has arrived.  Some of you developers and early adopters running the developer preview may need to use the Nokia Software Recovery Tool to downgrade back to Windows Phone 8 before you phone will recognize that the Lumia Cyan update is available.  Here at Microsoft, we’ve created the ultimate device to span your business and personal life.  Our super-efficient operating system runs great on inexpensive hardware so no one gets left out.  Highlights include:

Cortana

She’s a personal digital assistant (Did I just say PDA?) powered by Bing that keeps track of your interests, makes appointments, answers questions,  provides helpful suggestions and reminds you of meetings.

Action Center

With a swipe of you finger, you get notifications, messages, alerts and configurable control of functions like Wi-Fi, Bluetooth and brightness.

Start Screen

All devices get a third column of tiles with the option of making them translucent to reveal a background image.

Word Flow Keyboard

The world’s fastest keyboard (ask Guinness) delivers shape-writing out of the box, so get swiping.

Data Sense

This allows you to get the most out of your data plan by compressing images and text while warning you when you get close to the end of your plan.

Battery Saver

Extend your battery life up to 20%.

Internet Explorer 11

This hardware-accelerated, HTML5 web browser with JIT-compiled JavaScript supports unlimited tabs, InPrivate mode, inline video and reading mode.

Skype

Deep Skype integration allows you to upgrade incoming voice calls to video calls and Cortana is always happy to help you start a Skype call of any kind.

Volume

Select custom volume levels for the ringer, notifications, media, and apps while being able to quickly switch between silent or vibrate mode.

Device Encryption

BitLocker provides encryption for internal storage as well as the app partition of the SD card.

Enterprise Enrollment

Automatically configure devices for enrollment in Exchange, SharePoint, network profiles, certs and many other configurations all in a single step.

Certificates

Cert-based auth for accounts, Wi-Fi, VPN, web browser, and line of business apps.

Enterprise Wi-Fi

You get enterprise auth with PEAP-MSCHAPv2, EAP-TLS and EAP-TTLS so now you get to use certs for Wi-Fi authentication.

Virtual Private Networking

App-triggered VPN including IPSec (IKEv2), SSL-VPN, Intranet SSO, auto-reconnect and support for split or forced tunneling.

S/MIME

Exchange encrypted email messages.

App Allow/Deny

IT can now require apps to be pushed to devices for installation as well as blocking certain apps or even the entire Microsoft Store.

Workplace

Enroll devices with enterprise mobility management (EMM) solutions to enforce policies, provision profiles and distribute apps.

Windows Phone 8.1 not only fits the bill for BYOD scenarios but it has security and management capabilities needed to be a corporate-liable phone at your organization. I’m just scratching the surface here, so update your phone and find out for yourself.

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

NoSQL on Windows

In this week’s episode of “Inside Windows Phone,” Matthijs Hoekstra and I discuss the use of NoSQL.

When building mobile apps for the enterprise, an offline data store is absolutely essential so that users can keep working in the absence of wireless connectivity.  In addition to SQLite and SQLCE, NoSQL is a great option to consider in order to achieve your goals with local data storage.

Below are some code snippets I created to get you started:

Define Table schema (Entity)
public sealed class Customer
{
    public int CustomerId { getset; }
    public string FirstName { getset; }
    public string LastName { getset; }
}

Define Table (Generic List to hold collection of Customer objects)
public static List<Customer> Customers { getset; }

 

Create Table
Customers = new List<Customer>();

 

Save Table
public static async Task SaveChanges<T>(T collection, String tableName)
{
    var file = awaitApplicationData.Current.  LocalFolder.CreateFileAsync(tableName, CreationCollisionOption.ReplaceExisting);
    var outStream = await file.OpenStreamForWriteAsync();
    var serializer = new DataContractJsonSerializer(typeof(T));
    serializer.WriteObject(outStream, collection);
    await outStream.FlushAsync();
    outStream.Dispose();
}
 
Calling the Save Table Method
await SaveChanges<List<Customer>>(Customers, “Customer”);
 
Load Table
public static async Task<T> LoadTable<T>(string tableName)
{
    StorageFile file = awaitApplicationData.Current.
LocalFolder.GetFileAsync(tableName);
    Stream stream = await file.OpenStreamForReadAsync();
    DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
    T table = (T)serializer.ReadObject(stream);
    stream.Dispose();
    return table;
}
 
Calling the Load Table Method
Customers = await LoadTable<List<Customer>>(“Customer”);
 
INSERT Customers
Customers.Add(new Customer
{
    CustomerId = 1,
    FirstName = “Andy”,
    LastName = “Wigley”
});
 
UPDATE Customers
foreach (var item in Customers.Where((c) => c.CustomerId == 2))
{
    item.FirstName = “Mike”;
}
 
DELETE Customers
Customers.RemoveAll((c) => c.CustomerId == 2);
 
SELECT Customers
var query = from c in TableService.Customers
            select c;
CustomersList.ItemsSource = query.ToList();

 

Have fun!

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

Windows Phone 8 Emerges

Windows Phone 8 Tiles

The first glimpse of Windows Phone 8 emerged in San Francisco today.

Joe Belfiore, Terry Myerson, and Kevin Gallo took the world on a tour of Microsoft’s next smartphone.  I’m confident that Windows Phone 8 will leapfrog our smartphone competitors so dramatically that they’ll never catch up.  Before diving into the highlights of today’s Windows Phone Summit, just take a look at our beautiful new Start screen:

Windows Phone 8 Tiles

Windows Phone 8 is just Gorgeous!

I’m going to get you up to speed with our new phone as rapidly as possible, so hold on to your seat!

  1. Shares Windows 8 core > Kernel > Networking > Filesystem > Multimedia > Driver model > Security > Graphics
  2. Multi-core chipsets > Dual core coming this Fall
  3. More screen resolutions > WVGA > WXGA > 720p
  4. MicroSD cards > Removable storage for pictures, music > Sideload enterprise apps
  5. IE10 > Same as Windows 8 > 2x the HTML5 support and 4x JavaScript performance > App cache > IndexedDB > SmartScreen Filter
  6. Native Code > C/C++ for killer games with DirectX
  7. NFC > Sharing > Tap to pay
  8. Wallet > Credit cards > Coupons > Secure SIM > In-app purchasing
  9. Nokia Maps > Offline maps work without data connection > Turn by turn
  10. Enterprise > BitLocker > Secure boot > Device management > Private app distribution (on prem/cloud) > App sandboxing
  11. Start Screen > More tile sizes > S|M|L > More colors > More personal
  12. WP7/7.5 apps will run unchanged on WP8
  13. XAML/C#/VB apps > Compiled to machine code in the cloud to boost performance > Same for existing 7/7.5 apps
  14. SQLite open source libraries are available for Metro apps on W8 and WP8
  15. Multitasking > More things can run in the background > Location > Navigation
  16. Voice and Video > Integrated into platform > Just like traditional calls >  Accessible to developers
  17. Speech > Developers can add conversational speech to their apps
  18. Visual Studio 2012 > Single IDE to create Windows Phone 7/7.5/8 apps and games
  19. Hybrid apps > Browser control based on IE10
  20. Company Hub > Example of private app distribution > Self-service IT
  21. SDK > Available later this summer
  22. Launch partners > Nokia > Samsung > Huawei > HTC > Silicon from Qualcomm
  23. Global platform > 50 languages > Full RTL (Hebrew, Arabic)
  24. Software updates > Over the air (OTA) > No more tethering > Device updates for 18 months after launch
  25. Marketplace > 100,000 apps > 180 countries
  26. Upgrade > Existing WP7/7.5 devices are not upgradable to WP8 > Sorry > Next-Gen hardware needed
  27. Consolation Prize > Your existing WP7.5 device will get upgrade to WP7.8 > Gets  beautiful new Start Screen tiles
  28. Nokia > Updates to current Lumia devices > DLNA > Data/Voice usage counters > Music > Camera Extras > Nokia Drive

Let’s take one more look at our new Windows Phone 8 Start screen:

Windows Phone 8 Tiles

I hope you’re as thrilled as I am about Windows Phone 8!  Our journey begins today.  To learn more, join me and other members of the Windows Phone team in Amsterdam next week at TechEd Europe.

– Rob

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

Sign Up for my Newsletter and get a FREE Chapter of “Mobile Strategies for Business!”

[mc4wp_form id=”5975″]

HTML5 and CSS3 on Windows Phone: Simple Geolocation

Geolocation Page

Now that I’ve spent the last two articles helping you to get your Metro user experience foundation created with CSS3 and Media Queries, it’s time to jump into one of the features of HTML5Geolocation is perfectly suited for smartphones because location awareness is something they all have in common.  Most people are under the impression that only native mobile apps have the power to reach into the platform APIs and retrieve a device’s current location.  Luckily, with modern HTML5 browsers like Internet Explorer 9, web pages can use JavaScript to gather this same information.  This API finds your location via the following methods:

  • GPS:  This is the most accurate method but it requires you to be outdoors and has a reputation for draining batteries.
  • IP Address:  There’s a location database that maps IP addresses to locations which may or may not be accurate depending on how far away your DHCP server is from your current location.
  • Wi-Fi:  This also maps IP addresses to locations but also triangulates between Access Points.  It works indoors and may be relatively accurate.
  • Cell Tower Triangulation: This also works indoors and can be fairly accurate depending on how far apart the closest cellular towers are.

Let’s take a look at a simple page containing HTML and JavaScript:

<!DOCTYPE html>
<html lang=”en”>
<head>
    <meta charset=”utf-8″ />
    <meta name=”viewport” content=”width=device-width, initial-scale=1.0, user-scalable=yes” />
    <meta name=”MobileOptimized” content=”width” />
    <meta name=”HandheldFriendly” content=”true” />
    <link rel=”stylesheet” href=”MetroLight.css”>
    <title>Geolocation</title>
    </head>
<body>
<p>CONTOSO TRACKER</p>
<h4>Simple Geolocation</h4>
<form>
<fieldset>
<legend>Track</legend>
<button type=”button” id=”locationButton” onclick=”getPosition()”>Get Location</button>
</fieldset>
</form>
<script>
function getPosition() {
if (navigator.geolocation) {
navigator.geolocation.getCurrentPosition(displayLocation);
}
else {
alert(“No Geolocation Support”);
}
}
function displayLocation(position) {
var latitude = position.coords.latitude;
var longitude = position.coords.longitude;
alert(“You’re at Latitude: ” + latitude + “, Longitude: ” + longitude);
}
</script>
</body>
</html>

As you can see, I’ve taken our HTML5 + Mobile Web boilerplate and included the Light Metro stylesheet to get started.  Beyond that, it’s just a simple button designed to call a JavaScript function via the onclick event.  For the sake of this example, I’ve done the unthinkable and have included the JavaScript inside the web page.  Please never to this in production.

The onclick event calls the getPosition() function.  The first thing you should notice is a bit of defensive coding where I test to see if the navigator.geolocation capability exists.  If the target browser allows me to pass that test, I then call the getCurrentPosition() method and pass in a single arguement for the successCallback parameter.  Don’t worry, I’ll dive into the other two parameters in the next article.

The displayLocation callback function is called once the device passes the coordinates back to the web page.  After that, it’s a simple matter of retrieving the latitude and longitude values.

This first image below shows you what the mobile web page should look like when you run it on Windows Phone 7.5:

Geolocation Page

You should see the now-familair Light Metro UX.  When you click the Get Location button, IE9 will popup a dialog asking your permission to allow the web page to access your location from Windows Phone as shown below:

Geolocation Allow

This should give you comfort in knowing the Big Brother cannot anonymously track you.  You can say Yes or No for each Geolocation request and you can check the checkbox to remember your choice for this particular web page.  Once you’ve said Yes, the device will give you a lat/long as shown in the image below on the left:

Geolocation Coordinates

In order to more easily test this on my PC with Visual Studio 2010 running, I used the Windows Phone emulator, plus the additional tools you get with the Windows Phone 7.1 SDK.  By clicking on the Location tab, you can then click on the Bing map to get a Pushpin in a particular location.  The coordinates for the pushpin are displayed in the Current Location section which should match what you see in the emulator.  That’s all there is to it!

Congratulations!  You can now get lat/long coordinates without building an app.

Keep coding,

-Rob

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

Sign Up for my Newsletter and get a FREE Chapter of “Mobile Strategies for Business!”

[mc4wp_form id=”5975″]

HTML5 and CSS3 on Windows Phone: Dark and Light Styles

In my last article covering HTML5 and CSS3 on Windows Phone, I got you started with a simple boilerplate.

It just so happened that the style I presented you with was Dark.  Since we know that Windows Phone also has a light theme, I think it’s important that your mobile web site have one as well.  Below is an enhanced version of the boilerplate HTML5 file that displays many commonly used Form elements:

<!DOCTYPE html>
<html lang=”en”>
    <head>
        <meta charset=”utf-8″ />
        <meta name=”viewport” content=”width=device-width, initial-scale=1.0, user-scalable=yes” />
        <meta name=”MobileOptimized” content=”width” />
        <meta name=”HandheldFriendly” content=”true” />
        <link rel=”stylesheet” href=”MetroDark.css”>
        <title>Web Storage</title>
    </head>
    <body>
        <p>CONTOSO FRUIT COMPANY</p>
        <h4>Enter Products</h4>
        <form>
            <fieldset>
                <legend>Add</legend>
                <label id=”ValueLabel”>Product Name:</label>
                <br />
                <input id=’ValueInput’ type=’text’ />
                <br /><br />
                <label id=”StateLabel”>States:</label>
                <br />
                <select name=”states”>
                   <option value=”Washington”>Washington</option>
                   <option value=”Florida”>Florida</option>
                   <option value=”California”>California</option>
                </select>
                <br /><br />
                <label id=”RefLabel”>Refrigerate:</label>
                <br />
                <input type=”radio” name=”refrigerate” value=”yes” /> Yes
                <input type=”radio” name=”refrigerate” value=”no” /> No
                <br /><br /><br />
                <button id=’insertButton’>  Add Product  </button>
            </fieldset>
        </form>
    </body>
</html>

Here is the Dark CSS file that accompanies the above HTML5 file:

@media screen and (max-width:480px) {
    body {
        font-family: “Segoe WP”, Tahoma, Geneva, Verdana;
        background-color: #000000;
        color: #ffffff;
        padding: 5px;
    }
    h1, h2, h3, h4, h5, h6 {
    font-family:”Segoe WP Semibold”;
    margin-bottom:5px;
    }
    h1 {
    font-size: 48pt;
    }
    h2 {
    font-size: 40pt;
    }
    h3 {
    font-size:32pt;
    }
    h4{
    font-size:24pt;
    }
    h5 {
    font-size:20pt;
    }
    h6 {
    font-size:18pt;
    }
    p {
    font-size: 14pt;
    }
    input, select, button {
        color: #ffffff;
        background-color: #000000;
        border: 2px solid white;
        vertical-align: baseline;
        font-size: 17pt;
        min-width: 40px;
        min-height: 40px;
    }
    label {
    vertical-align:baseline;
    font-size:17pt;
    }
    input.hasfocus {
    background-color:white;
    color:black
    }
    fieldset, legend {
    font-family:”Segoe UI Semibold”;
    font-size:12pt;
    }
    fieldset {
    padding:12pt;
    border: 1px solid white;
    }
    legend {
        color: #ffffff;
    }
}

The combination of a mobile-optimized HTML5 page and a Dark Metro CSS3 stylesheet results in a familiar UX designed for AMOLED displays:

But what if you want to display a light mobile website?  Luckily, you get to use the same HTML5 page and just point to a new, Light Metro CSS stylesheet as shown below:

<link rel=”stylesheet” href=”MetroLight.css”>

So what does this new CSS file look like?  A lot like the dark one with some subtle changes:

@media screen and (max-width:480px) {
    body {
        font-family: “Segoe WP”, Tahoma, Geneva, Verdana;
        background-color: #ffffff;
        color: #000000;
        padding: 5px;
    }
    h1, h2, h3, h4, h5, h6 {
    font-family:”Segoe WP Semibold”;
    margin-bottom:5px;
    }
    h1 {
    font-size: 48pt;
    }
    h2 {
    font-size: 40pt;
    }
    h3 {
    font-size:32pt;
    }
    h4{
    font-size:24pt;
    }
    h5 {
    font-size:20pt;
    }
    h6 {
    font-size:18pt;
    }
    p {
    font-size: 14pt;
    }
    input, select, button {
        color: #000000;
        background-color: #ffffff;
        border: 2px solid black;
        vertical-align: baseline;
        font-size: 17pt;
        min-width: 40px;
        min-height: 40px;
    }
    label {
    vertical-align:baseline;
    font-size:17pt;
    }
    input.hasfocus {
    background-color:white;
    color:black
    }
    fieldset, legend {
    font-family:”Segoe UI Semibold”;
    font-size:12pt;
    }
    fieldset {
    padding:12pt;
    border: 1px solid black;
    }
    legend {
        color: #000000;
    }
}

With the Light Metro stylesheet, you now have a look and feel that’s reminiscent of the Outlook experience on Windows Phone.  With the black and white colors reversed, you get the following:

So there you have it!  You started with a simple HTML5/CSS3 boilerplate and now you’re building mobile web apps with both a Dark and Light Metro UI.  All the touchable elements are large enough for big fingers and the separation between controls ensures that users won’t hit two at the same time.  Consider this your foundation for a new HTML5 journey that you’ll be taking with Me, Internet Explorer, and Windows Phone.

Keep coding!

Rob

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

Sign Up for my Newsletter and get a FREE Chapter of “Mobile Strategies for Business!”

[mc4wp_form id=”5975″]

 

Windows Phone 7.5 wins 2012 Interaction Award

HTC Titan II

I’m excited to pass along the great news that our very own Windows Phone 7.5 is a 2012 Interaction Award winner!

In a field of over 300 entries from 33 countries, the compelling UX of Windows Phone stood out.  Our elegant integration of social networks, the Metro design language of color and typography, and the minimalist concept of fierce reduction won the day.

The Interaction Awards is an initiative of the Interaction Design Association (IxDA), which is a global network of over 25,000 members worldwide dedicated to the professional practice of Interaction Design.

Well done Windows Phone!

-Rob

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

Sign Up for my Newsletter and get a FREE Chapter of “Mobile Strategies for Business!”

[mc4wp_form id=”5975″]

Prediction: 2012 Will be the Year of Windows Phone

HTC Titan II

Windows Phone 7.5 is running fast out of the gate for 2012.

The stunning mobile operating system from Microsoft was the talk of CES in Las Vegas this year.  The accolades streaming in from the world’s most influential newspapers, magazines, reviewers, and tech bloggers are unprecedented.

The Nokia Lumia 900 won the Best of CES award in the Smartphone category and it’s no surprise.  Before listing off the impressive specs, just look at this gorgeous piece of hardware.  Looks matter…trust me.  Windows Phone is already the most elegant mobile operating system.  Breathtaking industrial design is the other half of the equation.  When paired with iconic hardware, it’s like pairing your favorite Walla Walla Cabernet with your favorite steak.

Nokia Lumia 900

I can’t count the number of reviews and comments stating that Windows Phone on the Lumia 900 has surpassed the iPhone.  If you follow the U.S. wireless market, then you know that things like 4G LTE network speeds, large screens, front-facing cameras, and dual-core processors are the current drivers of smartphone sales.  The Lumia 900 addresses three of those drivers with support for AT&T’s 4G LTE network, a 4.3-inch AMOLED ClearBlack display, and a front-facing camera for video calls.  It’s powered by a single 1.4 GHz processor and if you’ve paid attention to all the reviews in the press, you’ve heard that Windows Phone runs circles around its dual-core competitors.  Better software design, better engineering, more efficient algorithms, and optimized coding techniques means you can do more with less.  Last but not least, the Lumia 900 comes with an amazing 8MP camera with Carl Zeiss optics.

The HTC Titan II came to the CES party guns-blazing with a monster of a smartphone.  It tics all the required boxes needed for sales by delivering a massive 4.7 inch screen, support for AT&T’s 4G LTE network, and a front-facing camera.  The 1.5Ghz Snapdragon 2 processor gives this superphone all the horsepower it needs.

HTC Titan II

Joining the camera arms-race with the Lumia 900, the Titan II comes equipped with a whopping 16 megapixel camera that can capture 720p video.  If you’re looking for a giant phone that can go head-to-head with the Galaxy Nexus, this is your device.

2012 is already shaping up to be a great year with compelling hardware matched-up with Windows Phone 7.5, but what else does this platform need to make my prediction come true?  Oh yeah, apps.  Do you remember back in the 80’s when DOS-based PCs from IBM and Compaq gave Apple IIs and Macs more than they could handle?  It might not have been eye-catching, but DOS had more apps that allowed consumers and companies to be successful.  In the 90’s, Windows ran away with the computing market with the Mac, Linux, NeXT, and OS/2 unable to compete in the app department.  Why do you think this was the case?  I know a big reason was because Borland and Microsoft made better and easier-to-use development tools for Windows.

With 50,000+ apps in the Marketplace, Windows Phone is surging forward and now sits in third-place behind the iPhone App Store and the Android Market.  Aside from developers betting on the success of a platform, they need development tools, emulators, and programming languages that make it easy for them to be productive.  When I look at the velocity at which new apps are being added to the Windows Phone Marketplace, it tells me that Visual Studio is making a big difference.

Visual Studio

In my job, I have to work with the development tools for all the major smartphone platforms and I can tell you without drinking any Kool-Aid that the competition isn’t even close.  Most iPhone developers I know find that learning Objective-C from the NeXT operating system to be a daunting task compared to modern, high-level languages like C# and VB.  While the world is full of Java developers, the complexity of cobbling the necessary tools together needed to build for Android apps is a real productivity killer.  Just running Eclipse on JDK 1.6 sucks the life and performance out of my fast Windows 7 laptop.  Microsoft Visual Studio 2010 Express for Windows Phone is free and the emulator + SDKs all download and install together making the whole process fast and simple.  Apps get access to all phone sensors, a local database (SQL Server Compact), and Metro design.

Better productivity means faster time-to-market which means more apps for Windows Phone.

If you’re a web designer/developer, Internet Explorer 9 is alive and well on Windows Phone 7.5.  This means you’re no longer held hostage to the highly-fragmented WebKit mobile browser platform.  You get a hardware-accelerated, amazingly fast browser with support for more “fully-baked” HTML5 standards like Web Storage, Geolocation, Canvas, Audio and Video.

HTML5

The lightning fast-Chakra JavaScript engine supports ECMAScript 5 which means your DOM interactions and Ajax web service calls will blur the lines with native apps.  When you retrieve data from the cloud or your on-premise servers via Ajax, you’ll now be able to persist it offline in Web Storage.  Support for CSS3 means things will be beautiful, 2D transforms will occur, and media queries will give you responsive design.

So here we stand with the best smartphone operating system, best hardware, best development tools and the best mobile web browser.  I’m certain that Windows Phone with its army of app developers, OEMs and Mobile Operator partners will be marching to victory this year.

Be fearless,

Rob

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

Sign Up for my Newsletter and get a FREE Chapter of “Mobile Strategies for Business!”

[mc4wp_form id=”5975″]

Encrypting your Credentials on Windows Phone 7.5

Azure Security

The last time I talked to you about Windows Phone security, I showed you how to encrypt your data and save it in Isolated Storage using Silverlight’s AesManaged class to create a Key and an Initialization Vector (IV) based on a password and salt value. 

This gave your consumer and line-of-business apps the iron-clad AES 256 encryption they needed to secure sensitive data.  While this made 3rd-party Windows Phone apps the most secure in the industry, users had to deal with the hassle of entering their credentials each time they launched their secure app. 

The reason users had to reenter their credentials each time is because there was no secure way to store those credentials or the key in Isolated Storage.  Having the unencrypted credentials used to create the key sitting next to the encrypted data is the same as having no security at all.  With the launch of Mango, all this has changed.

Windows Phone 7.5 gives us the Data Protection API (DPAPI) which makes it easy to encrypt and decrypt data.  It pulls this off by generating and storing a key based on the user and phone credentials.  Oh, and it gets its own decryption key, which is created the first time you run the app that’s doing the encrypting. 

Using the ProtectedData class, it’s as simple as calling the Protect method to turn an unencrypted byte array into an encrypted one.  On the flip side, you call the Unprotect method to convert an encrypted byte array into an unencrypted one.  In cases where the data stays on the phone, this may take care of all of your encryption needs and you won’t necessarily have to jump through all the AesManaged hoops I had you jump through back before we launched Windows Phone 7.  On the other hand, if you want to encrypt data on Windows Phone, send it over a network and decrypt it on a server or other endpoint, you need to stick with the stuff I taught you before.

Below is a snippet of code that shows you how to encrypt the password and salt values needed to create a key with the AesManaged class:

 

using System.Security.Cryptography;

 

//Convert Password and Salt values to byte[] arrays

byte[] PasswordByte = Encoding.UTF8.GetBytes(Password.Text);

byte[] SaltByte = Encoding.UTF8.GetBytes(Salt.Text);

 

//Encrypt Password and Salt byte[] arrays using Protect() method

byte[] ProtectedPasswordByte = ProtectedData.Protect(PasswordByte, null);

byte[] ProtectedSaltByte = ProtectedData.Protect(SaltByte, null);

 

//Save byte[] arrays as two files in Isolated Storage

//Read byte[] arrays from files

 

 

//Decrypt Password and Salt byte[] arrays using Unprotect() method

byte[] PasswordByte = ProtectedData.Unprotect(ProtectedPasswordByte, null);

byte[] SaltByte = ProtectedData.Unprotect(ProtectedSaltByte, null);

 

//Convert byte[] arrays to strings and display in the text boxes

Password.Text = Encoding.UTF8.GetString(PasswordByte, 0, PasswordByte.Length);

Salt.Text = Encoding.UTF8.GetString(SaltByte, 0, SaltByte.Length);

 

With this simple code above, you can now encrypt and decrypt your credentials so you can save them in Isolated Storage next to the portable, encrypted data created via the AesManaged class.  So what does this buy you?

It means your users can enter their credentials just once, no matter how many times they launch your secure application.  Hassle-free.

Stay safe out there,

Rob

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

Sign Up for my Newsletter and get a FREE Chapter of “Mobile Strategies for Business!”

[mc4wp_form id=”5975″]

How Not to Present a Session at a Techical Conference

Windows Mobile

Prior to the Mobile and Embedded Developer Conference (MEDC) back in 2007, my teammates Loke Uei Tan, Mike Hall, James Pratt, Derek Snyder and I made a movie that illustrates presentation worst practices…

Enjoy,
Rob

Sharing my knowledge and helping others never stops, so connect with me on my blog at http://robtiffany.com , follow me on Twitter at https://twitter.com/RobTiffany and on LinkedIn at https://www.linkedin.com/in/robtiffany

Sign Up for my Newsletter and get a FREE Chapter of “Mobile Strategies for Business!”

[mc4wp_form id=”5975″]