IDataProtector 保护和取消保护字符串
IDataProtector protect and unprotect strings
我在 Asp.Net 核心应用程序(blazor 服务器)中引用了此 link 会话保护:
但是在将 IDataProtector 注入组件后,protect 和 unprotect 方法仅获取 byte[] 作为参数,我想使用字符串作为 protect 和 unprotect 方法,如上所示 link。
在此库中启用字符串保护需要哪些名称空间或包或任何其他工作?
我在我的 .netcore3.1 应用程序中使用 Microsoft.AspNetCore.DataProtection 命名空间。
我在 class DataProtectionCommonExtensions 下看到 protector.Protect(), protector.Unprotect() 接受字符串作为参数。
在看到 OP 中提到的文档之前,我参考了 this。
namespace Microsoft.AspNetCore.DataProtection {
public static class DataProtectionCommonExtensions{
public static string Protect(this IDataProtector protector, string plaintext);
public static string Unprotect(this IDataProtector protector, string protectedData);
}
}
我在 Asp.Net 核心应用程序(blazor 服务器)中引用了此 link 会话保护:
但是在将 IDataProtector 注入组件后,protect 和 unprotect 方法仅获取 byte[] 作为参数,我想使用字符串作为 protect 和 unprotect 方法,如上所示 link。 在此库中启用字符串保护需要哪些名称空间或包或任何其他工作?
我在我的 .netcore3.1 应用程序中使用 Microsoft.AspNetCore.DataProtection 命名空间。 我在 class DataProtectionCommonExtensions 下看到 protector.Protect(), protector.Unprotect() 接受字符串作为参数。
在看到 OP 中提到的文档之前,我参考了 this。
namespace Microsoft.AspNetCore.DataProtection {
public static class DataProtectionCommonExtensions{
public static string Protect(this IDataProtector protector, string plaintext);
public static string Unprotect(this IDataProtector protector, string protectedData);
}
}