blob: 36b8c074d8f78b7ed1e726ba2a743889a916ca09 [file] [log] [blame]
Don Newton379ae252019-04-01 12:17:06 -04001// Copyright (C) MongoDB, Inc. 2017-present.
2//
3// Licensed under the Apache License, Version 2.0 (the "License"); you may
4// not use this file except in compliance with the License. You may obtain
5// a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
6
7package auth
8
9import (
10 "crypto/md5"
11 "fmt"
12 "io"
13)
14
15const defaultAuthDB = "admin"
16
17func mongoPasswordDigest(username, password string) string {
18 h := md5.New()
19 _, _ = io.WriteString(h, username)
20 _, _ = io.WriteString(h, ":mongo:")
21 _, _ = io.WriteString(h, password)
22 return fmt.Sprintf("%x", h.Sum(nil))
23}