csrf/unauth_make.go

21 lines
448 B
Go
Raw Permalink Normal View History

2025-01-12 11:40:15 +00:00
package csrf
import (
"crypto/md5"
"fmt"
"strconv"
"time"
)
// userless CSRF
func (c CSRF) UnauthMake(routename string) string {
//shorter time scales
// h := sha256.New()
// get time in 10 minute chunks
minfactor := strconv.Itoa(time.Now().Minute() / 10)
res := fmt.Sprintf("%x", md5.Sum([]byte(routename+c.CSRFKey+minfactor)))
// h.Write([]byte(routename + CSRFKey + minfactor))
// res := fmt.Sprintf("%x", h.Sum(nil))
return res
}