INNER CODE UNIT · Go
Get7MoorSigAuth
feiyu563/PrometheusAlert · controllers/7moor.go:38
func Get7MoorSigAuth() (string, string) {
accountID := beego.AppConfig.String("7MOOR_ACCOUNT_ID")
accountAPISecret := beego.AppConfig.String("7MOOR_ACCOUNT_APISECRET")
now := time.Now()
// 7moor time format
calltime := now.Format("20060102150405")
// generate sig
signature := strings.Join([]string{accountID, accountAPISecret, calltime}, "")
sigdata := []byte(signature)
sighas := md5.Sum(sigdata)
sigMd5 := strings.ToUpper(fmt.Sprintf("%x", sighas))
// generate authorization
authorization := strings.Join([]string{accountID, calltime}, ":")
authBase64 := base64.StdEncoding.EncodeToString([]byte(authorization))
return sigMd5, authBase64
}