【发布时间】:2020-07-02 08:20:02
【问题描述】:
我正在尝试使用MD5CryptoServiceProvider 加密的密码将我现有的用户数据库导入 Firebase。我似乎无法让它发挥作用,至少使用 C# 中的 Firebase Admin SDK。
它给我的错误是无法将 system.Security.Cryptography.md5cryptoserviceprovider 隐式转换为 firebase_admin.auth.user 导入哈希
这是我的代码:
try
{
string password = "hashed_password";
var users = new List<ImportUserRecordArgs>()
{
new ImportUserRecordArgs()
{
Uid = "some-uid",
Email = "user@example.com",
PasswordHash = Encoding.ASCII.GetBytes(password),
PasswordSalt = null,
},
};
var options = new UserImportOptions()
{
Hash = new MD5CryptoServiceProvider()
{
//Key = md5.ComputeHash(Encoding.ASCII.GetBytes(text))
},
};
UserImportResult result = await FirebaseAuth.DefaultInstance.ImportUsersAsync(users, options);
foreach (ErrorInfo indexedError in result.Errors)
{
Console.WriteLine($"Failed to import user: {indexedError.Reason}");
}
}
catch (FirebaseAuthException e)
{
Console.WriteLine($"Error importing users: {e.Message}");
}
我的问题是,我应该如何配置 UserImportedOptions 才能正常工作...
我为此使用 C#。
【问题讨论】:
标签: c# firebase-authentication cryptography md5