MCPcopy Create free account
hub / github.com/IceFireDB/IceFireDB / CalcPassword

Function CalcPassword

IceFireDB-SQLite/pkg/mysql/mysql/util.go:24–51  ·  view source on GitHub ↗
(scramble, password []byte)

Source from the content-addressed store, hash-verified

22}
23
24func CalcPassword(scramble, password []byte) []byte {
25 if len(password) == 0 {
26 return nil
27 }
28
29 // stage1Hash = SHA1(password)
30 crypt := sha1.New()
31 crypt.Write(password)
32 stage1 := crypt.Sum(nil)
33
34 // scrambleHash = SHA1(scramble + SHA1(stage1Hash))
35 // inner Hash
36 crypt.Reset()
37 crypt.Write(stage1)
38 hash := crypt.Sum(nil)
39
40 // outer Hash
41 crypt.Reset()
42 crypt.Write(scramble)
43 crypt.Write(hash)
44 scramble = crypt.Sum(nil)
45
46 // token = scrambleHash XOR stage1Hash
47 for i := range scramble {
48 scramble[i] ^= stage1[i]
49 }
50 return scramble
51}
52
53// CalcCachingSha2Password: Hash password using MySQL 8+ method (SHA256)
54func CalcCachingSha2Password(scramble []byte, password string) []byte {

Callers 3

genAuthResponseMethod · 0.50

Calls 1

ResetMethod · 0.45

Tested by

no test coverage detected