Uploaded image for project: 'C# Driver'
  1. C# Driver
  2. CSHARP-1026

Need to be able to convert a password to its hash value using c#

    XMLWordPrintableJSON

Details

    • Icon: Task Task
    • Resolution: Done
    • Icon: Major - P3 Major - P3
    • None
    • None
    • None

    Description

      I am trying to come up with a C# code to add users to a mongodb database.
      I have the below code, and need the password to be in a password hash format to insert it into system.users. Can you tell me if there any built-in function in c#, or any other price of code that I can use to convert a password into the hash format before inserting it into system.users?

      var user = new MongoUser("foouser", new PasswordEvidence("foopassword"), true); var database = server.GetDatabase("admin"); var usersCollection = database.GetCollection("system.users");
      var userDocument = new BsonDocument
      {

      { "user", user.Username }

      ,

      { "pwd", user.PasswordHash }

      ,

      { "roles", new BsonArray() }

      ,
      { "otherDBRoles", new BsonDocument("productDB", new BsonArray

      { "readWrite" }

      ) } }; usersCollection.Insert(userDocument);

      Attachments

        Activity

          People

            Unassigned Unassigned
            jayashree_v_p Jaya
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: