Microsoft.HockeyApp.AuthManager.StoreStringProtectedAsync C# (CSharp) Méthode

StoreStringProtectedAsync() private méthode

Store data encrypted in the isolatedStorage
private StoreStringProtectedAsync ( string dataIdentifier, string data ) : System.Threading.Tasks.Task
dataIdentifier string identifier for the data to write
data string the data to store
Résultat System.Threading.Tasks.Task
        internal async Task StoreStringProtectedAsync(string dataIdentifier, string data)
        {
            DataProtectionProvider Provider = new DataProtectionProvider("LOCAL=user");

            IBuffer buffMsg = CryptographicBuffer.ConvertStringToBinary(data, BinaryStringEncoding.Utf8);

            // Encrypt the message.
            IBuffer buffProtected = await Provider.ProtectAsync(buffMsg);

            var file = await ApplicationData.Current.LocalFolder.CreateFileAsync(dataIdentifier + ConstantsUniversal.EncryptedFileExt, CreationCollisionOption.ReplaceExisting);
            using (var stream = await file.OpenStreamForWriteAsync())
            {
                await stream.WriteAsync(buffProtected.ToArray(),0,(int)buffProtected.Length);
            }
        }