此C#代码块的非UWP翻译是什么?

时间:2019-02-16 14:16:59

标签: c# uwp

我正在使用一个API示例。如文档注释中所述,此特定代码块已针对Windows Store。 什么是“非Windows Store”调用翻译?

using System;
using System.IO;
using System.Net;
using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;      



    protected string Sha256Encode(string stringToEncode)
    {
        // Note: Windows Store specific namespaces used here.  You may need to use slightly different calls for 
        // server-side implementations.
        //What is the non windows store version of this block of code?
        IBuffer buffUtf8Msg = CryptographicBuffer.ConvertStringToBinary(stringToEncode, BinaryStringEncoding.Utf8);
        HashAlgorithmProvider objAlgProv = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha256);

        // Hash the string
        IBuffer buffHash = objAlgProv.HashData(buffUtf8Msg);
        string result = CryptographicBuffer.EncodeToHexString(buffHash);

        return result;
    }

0 个答案:

没有答案