Exemple #1
0
func (w *OkcoinTrade) createSign(pParams map[string]string) string {
	ms := util.NewMapSorter(pParams)
	sort.Sort(ms)

	v := url.Values{}
	for _, item := range ms {
		v.Add(item.Key, item.Val)
	}

	h := md5.New()

	io.WriteString(h, v.Encode()+w.secret_key)
	sign := fmt.Sprintf("%X", h.Sum(nil))

	return sign
}
Exemple #2
0
func (w *PeatioTrade) createSign(pParams map[string]string) string {
	pParams["secret_key"] = w.secret_key

	ms := util.NewMapSorter(pParams)
	sort.Sort(ms)

	v := url.Values{}
	for _, item := range ms {
		v.Add(item.Key, item.Val)
	}

	key := []byte("todo")
	h := hmac.New(sha256.New, key)

	io.WriteString(h, v.Encode())
	sign := fmt.Sprintf("%x", h.Sum(nil))

	return sign
}