<commit_before>package forgotpwdemail

import (
	"crypto/sha1"
	"fmt"
	"io"
	"time"

	"github.com/skygeario/skygear-server/pkg/auth/dependency/userprofile"

	"github.com/skygeario/skygear-server/pkg/core/auth/authinfo"
)

type CodeGenerator struct {
	MasterKey string
}

func (c *CodeGenerator) Generate(
	authInfo authinfo.AuthInfo,
	userProfile userprofile.UserProfile,
	hashedPassword []byte,
	expireAt time.Time,
) string {
	h := sha1.New()
	io.WriteString(h, c.MasterKey)
	io.WriteString(h, authInfo.ID)
	if email, ok := userProfile.Data["email"].(string); ok {
		io.WriteString(h, email)
	}
	io.WriteString(h, expireAt.Format(time.RFC3339))
	if len(hashedPassword) > 0 {
		h.Write(hashedPassword)
	}
	if authInfo.LastLoginAt != nil && !authInfo.LastLoginAt.IsZero() {
		io.WriteString(h, authInfo.LastLoginAt.Format(time.RFC3339))
	}

	bs := h.Sum(nil)
	return fmt.Sprintf("%x", bs)[0:8]
}<commit_msg>Use sha256 instead of sha1 to fix lint<commit_after>package forgotpwdemail

import (
	"crypto/sha256"
	"fmt"
	"io"
	"time"

	"github.com/skygeario/skygear-server/pkg/auth/dependency/userprofile"

	"github.com/skygeario/skygear-server/pkg/core/auth/authinfo"
)

type CodeGenerator struct {
	MasterKey string
}

func (c *CodeGenerator) Generate(
	authInfo authinfo.AuthInfo,
	userProfile userprofile.UserProfile,
	hashedPassword []byte,
	expireAt time.Time,
) string {
	h := sha256.New()
	io.WriteString(h, c.MasterKey)
	io.WriteString(h, authInfo.ID)
	if email, ok := userProfile.Data["email"].(string); ok {
		io.WriteString(h, email)
	}
	io.WriteString(h, expireAt.Format(time.RFC3339))
	if len(hashedPassword) > 0 {
		h.Write(hashedPassword)
	}
	if authInfo.LastLoginAt != nil && !authInfo.LastLoginAt.IsZero() {
		io.WriteString(h, authInfo.LastLoginAt.Format(time.RFC3339))
	}

	bs := h.Sum(nil)
	return fmt.Sprintf("%x", bs)[0:8]
}
{'fraction_non_alphanumeric': 0.14867064568638091, 'fraction_numerical': 0.018448182311448725, 'mean_word_length': 4.948387096774193, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1777260', 'n_tokens_mistral': 755, 'n_tokens_neox': 719, 'n_words': 121}