【问题标题】:Import users into Firebase with password encrypted with MD5CryptoServiceProvider使用 MD5CryptoServiceProvider 加密的密码将用户导入 Firebase
【发布时间】: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


    【解决方案1】:

    知道了,只是使用的问题

          var options = new UserImportOptions()
                {
                    Hash = new Md5
                    {
                        Rounds = 0
                    },
                };
    

    【讨论】:

      猜你喜欢
      • 2019-05-04
      • 1970-01-01
      • 2016-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-11
      • 1970-01-01
      • 2010-10-23
      相关资源
      最近更新 更多