package utils

import (
	"crypto/hmac"
	"encoding/hex"
	"golang.org/x/crypto/ripemd160"
	"time"
)

//加密token
func EncryptionToken(token string, secret string) (sha1 string) {
	message := []byte(token)
	key := []byte(secret)
	mac := hmac.New(ripemd160.New, key)
	mac.Write(message)
	expectedMAC := mac.Sum(nil)
	shaData := hex.EncodeToString(expectedMAC)
	sha1 = string(shaData)
	return
}



func ParseTimestrToTimestamp(timeStr string) int64 {
	loc, _ := time.LoadLocation("Local")
	t1, _ := time.ParseInLocation("2006-01-02 15:04:05", timeStr, loc)
	return t1.Unix()
}

