func Sha1Hash(bs []byte) []byte {
	crypt := sha1.New()
	_, err := crypt.Write(bs)
	terror.Log(errors.Trace(err))
	return crypt.Sum(nil)
}
Sha1Hash is an util function to calculate sha1 hash.
package auth
import (
	"bytes"
	"crypto/sha1"
	"encoding/hex"
	"fmt"
	"github.com/pingcap/errors"
	"github.com/pingcap/parser/terror"
)
type UserIdentity struct {
	Username     string
	Hostname     string
	CurrentUser  bool
	AuthUsername string  
	AuthHostname string  
}
func (user *UserIdentity) String() string {
	return fmt.Sprintf("%s@%s", user.Username, user.Hostname)
}
func (user *UserIdentity) AuthIdentityString() string {
	return fmt.Sprintf("%s@%s", user.AuthUsername, user.AuthHostname)
}
func CheckScrambledPassword(salt, hpwd, auth []byte) bool {
	crypt := sha1.New()
	_, err := crypt.Write(salt)
	terror.Log(errors.Trace(err))
	_, err = crypt.Write(hpwd)
	terror.Log(errors.Trace(err))
	hash := crypt.Sum(nil)
	for i := range hash {
		hash[i] ^= auth[i]
	}
	return bytes.Equal(hpwd, Sha1Hash(hash))
}