We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 55d7dfb commit 93e73b9Copy full SHA for 93e73b9
mysql/util.go
@@ -56,12 +56,11 @@ func CalcNativePassword(scramble, password []byte) []byte {
56
return Xor(scrambleHash, stage1)
57
}
58
59
-// Xor returns a new slice with hash1 XOR hash2
+// Xor returns a new slice with hash1 XOR hash2, wrapping hash2 if hash1 is longer.
60
func Xor(hash1 []byte, hash2 []byte) []byte {
61
- l := min(len(hash1), len(hash2))
62
- result := make([]byte, l)
63
- for i := range l {
64
- result[i] = hash1[i] ^ hash2[i]
+ result := make([]byte, len(hash1))
+ for i := range hash1 {
+ result[i] = hash1[i] ^ hash2[i%len(hash2)]
65
66
return result
67
0 commit comments