小编NP3*_*NP3的帖子

UWP - 跨设备数据加密

我的UWP应用程序以加密形式将数据存储在设备上的本地SQLite数据库中.我使用Windows.Security.Cryptography.DataProtection静态数据类和数据流加密/解密(参考:https://docs.microsoft.com/en-us/windows/uwp/security/cryptography)

我提供了OneDrive数据备份工具,用户可以从一台设备将整个数据库备份到OneDrive,并在另一台设备上安装的应用程序中恢复它.这可以帮助用户在多个设备上使用应用程序,以及用户获取新设备的情况.

"LOCAL=user"DataProtectionProvider课堂上使用Descriptor (参考:https://docs.microsoft.com/en-us/uwp/api/windows.security.cryptography.dataprotection.dataprotectionprovider)

我希望如果我在两个不同的设备上使用我的Microsoft帐户登录并在一台设备上加密数据,然后在其他设备上恢复数据,那么数据应该被解密; 然而这并没有发生.

我也无法获得任何文档(除了上面列出的参考文献).我也搜索了MS以获得MS支持,但没有运气.有人可以帮我这个吗?

我的要求:在一个(Windows)设备上加密的数据应该在其他(Windows)设备中解密(当用户在两个设备上使用相同的Microsoft帐户登录时).

[UPDATE]

这是代码示例:

const BinaryStringEncoding encoding = BinaryStringEncoding.Utf8;
        const string strDescriptor = "LOCAL=user";        

public static async Task<string> ProtectTextAsync(string strClearText)

    {
        DataProtectionProvider Provider = new DataProtectionProvider(strDescriptor);

        IBuffer buffMsg = CryptographicBuffer.ConvertStringToBinary(strClearText, encoding);

        IBuffer buffProtected = await Provider.ProtectAsync(buffMsg);

        return CryptographicBuffer.EncodeToBase64String(buffProtected);
    }

    public static async Task<String> UnprotectTextAsync(string strProtected)
    {
        DataProtectionProvider Provider = new DataProtectionProvider();

        IBuffer buffProtected = CryptographicBuffer.DecodeFromBase64String(strProtected);

        IBuffer buffUnprotected = await Provider.UnprotectAsync(buffProtected); …
Run Code Online (Sandbox Code Playgroud)

c# security encryption uwp

12
推荐指数
1
解决办法
639
查看次数

标签 统计

c# ×1

encryption ×1

security ×1

uwp ×1