diff --git a/meter/fritzdect/fritzdect.go b/meter/fritzdect/fritzdect.go index 8e148289b..ef28e850d 100644 --- a/meter/fritzdect/fritzdect.go +++ b/meter/fritzdect/fritzdect.go @@ -181,9 +181,8 @@ func createChallengeResponse(challenge, pass string) (string, error) { return "", err } - hash := md5.New() - hash.Write([]byte(utf16le)) + hash := md5.Sum([]byte(utf16le)) + md5hash := hex.EncodeToString(hash[:]) - md5hash := hex.EncodeToString(hash.Sum(nil)) return challenge + "-" + md5hash, nil } diff --git a/vehicle/aiways/identity.go b/vehicle/aiways/identity.go index d09c900af..08ff78696 100644 --- a/vehicle/aiways/identity.go +++ b/vehicle/aiways/identity.go @@ -30,11 +30,9 @@ func NewIdentity(log *util.Logger) *Identity { } func (v *Identity) Login(user, password string) (int64, error) { - hash := md5.New() - hash.Write([]byte(password)) - + hash := md5.Sum([]byte(password)) + v.hash = hex.EncodeToString(hash[:]) v.user = user - v.hash = hex.EncodeToString(hash.Sum(nil)) var res User diff --git a/vehicle/niu.go b/vehicle/niu.go index c3a6c618a..ebcca1235 100644 --- a/vehicle/niu.go +++ b/vehicle/niu.go @@ -69,9 +69,8 @@ func NewNiuFromConfig(other map[string]any) (api.Vehicle, error) { // login implements the Niu oauth2 api func (v *Niu) login() error { - hash := md5.New() - hash.Write([]byte(v.password)) - md5hash := hex.EncodeToString(hash.Sum(nil)) + hash := md5.Sum([]byte(v.password)) + md5hash := hex.EncodeToString(hash[:]) data := url.Values{ "account": {v.user}, diff --git a/vehicle/smart/hello/helper.go b/vehicle/smart/hello/helper.go index 96dcd514a..d6717a183 100644 --- a/vehicle/smart/hello/helper.go +++ b/vehicle/smart/hello/helper.go @@ -25,9 +25,8 @@ func createSignature(method, path string, params url.Values, body io.Reader) (st return "", "", "", err } - hash := md5.New() - hash.Write(bytes) - md5Hash = base64.StdEncoding.EncodeToString(hash.Sum(nil)) + hash := md5.Sum(bytes) + md5Hash = base64.StdEncoding.EncodeToString(hash[:]) } payload := fmt.Sprintf(`application/json;responseformat=3