20 lines
448 B
Go
20 lines
448 B
Go
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
|
|
}
|