Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Threading.Tasks;
using Windows.ApplicationModel.Activation;
using Windows.ApplicationModel.Core;
using Windows.Storage;
using Windows.Storage.Pickers;
using Windows.Storage.Streams;
namespace Pinnacle.Pickers
{
// WinRT Implementation of the base Behavior classes
public abstract class Behavior<T> : Behavior where T : DependencyObject
{
protected T AssociatedObject
{
get { return base.AssociatedObject as T; }
}
protected override void OnAttached()
{
@skendrot
skendrot / TrialService
Created July 24, 2014 03:56
Service for determining if a user's trial has expired.
class AzureTrialService : ITrialService
{
private readonly IMobileServiceClient _service;
public AzureTrialService(IMobileServiceClient service)
{
_service = service;
TrialPeriod = TimeSpan.FromDays(7);
}
@skendrot
skendrot / gist:2b2b529605f0b07aba55
Created June 5, 2014 16:03
Pcl Crypto conversion
private static string EncryptData(PublicKey key, string plainText)
{
byte[] exponent = HexToBytes(key.Exponent);
byte[] modulus = HexToBytes(key.Modulus);
//**************** NEW **************************
IAsymmetricKeyAlgorithmProvider provider = PCLCrypto.WinRTCrypto.AsymmetricKeyAlgorithmProvider.OpenAlgorithm(AsymmetricAlgorithm.RsaSignPssSha512);
byte[] keyBlob == null; // how to convert my PublicKey class?
ICryptographicKey cryptographicKey = provider.ImportKeyPair(keyBlob)