Пример #1
0
func generateLink() string {
	link := utils.Md5String(time.Now().Format(time.RFC3339Nano))[8:16]
	// read database, make sure link is unique
	if article, _ := model.GetArticleByLink(link); article != nil {
		return generateLink()
	}
	return link
}
Пример #2
0
// encode password string, return encoded string and salt
func EncodePassword(pwd string) (string, string) {
	tmp := time.Now().Format(time.RFC3339)
	salt := utils.Md5String(tmp)[8:24]
	return utils.Sha256String(pwd + salt), salt
}
Пример #3
0
// encode token value to hash
func (t *Token) EncodeValue() {
	t.Value = utils.Md5String(t.Value)
	t.Value = utils.Md5String(t.Value)
	t.Value = utils.Md5String(t.Value)
}