我在我的应用程序中使用Credential Picker进行用户身份验证。我的数据库中的身份验证详细信息是字符串格但Credential Picker传递的密码是加密形式(默认情况下是协商身份验证协议),那么如何解密该密码以便我可以匹配我的数据库密码。 使用DB存储密码进行密码匹配的最佳和正确的解决方案是什么? 下面是代码片段:
function launchCredentialPicker() {
Windows.Security.Credentials.UI.CredentialPicker.pickAsync("My Target", "My Message", "my Caption").then(function (results) {
var domainName = results.credentialDomainName;
WinJS.Application.sessionState.Username = results.credentialUserName;
WinJS.Application.sessionState.Password = results.credentialPassword;
WinJS.Application.sessionState.RememberPassword = (results.credentialSaveOption === Windows.Security.Credentials.UI.CredentialSaveOption.hidden) ? "Hidden" :
((results.credentialSaveOption === Windows.Security.Credentials.UI.CredentialSaveOption.selected) ? "Selected" : "Unselected");
});
}
答案 0 :(得分:3)
您需要使用CredentialPickerOptions
对象PickAsync
CredentialPicker
方法。配置CredentialPickerOptions
以使用基本身份验证后,您将能够看到用户输入的密码。
var options = new Windows.Security.Credentials.UI.CredentialPickerOptions();
options.authenticationProtocol = Windows.Security.Credentials.UI.AuthenticationProtocol.basic;
Windows.Security.Credentials.UI.CredentialPicker.pickAsync(options).then(/* */);