Debian Codegraph @

ldap/ldap.go

raw symbols SCIP
1 package ldap
2
3 import (
4 "bytes"
5 "hash"
6 )
7
8 // Key returns the RFC2307 key for the provided password and optional salt. Generally this is encoded with base64.
9 func Key(hashFunc func() hash.Hash, password, salt []byte) []byte {
10 s := len(salt) != 0
11
12 digest := hashFunc()
13
14 digest.Write(password)
15
16 if s {
17 digest.Write(salt)
18 }
19
20 buf := &bytes.Buffer{}
21
22 buf.Write(digest.Sum(nil))
23
24 digest.Reset()
25
26 if s {
27 buf.Write(salt)
28 }
29
30 return buf.Bytes()
31 }