MCPcopy Create free account
hub / github.com/FloatTech/AnimeAPI / wbiSign

Function wbiSign

bilibili/wbi.go:66–92  ·  view source on GitHub ↗
(params map[string]string, imgKey string, subKey string)

Source from the content-addressed store, hash-verified

64}
65
66func wbiSign(params map[string]string, imgKey string, subKey string) map[string]string {
67 mixinKey := getMixinKey(imgKey + subKey)
68 currTime := strconv.FormatInt(time.Now().Unix(), 10)
69 params["wts"] = currTime
70 // Sort keys
71 keys := make([]string, 0, len(params))
72 for k, v := range params {
73 keys = append(keys, k)
74 for _, old := range replacements {
75 v = strings.ReplaceAll(v, old, "")
76 }
77 params[k] = v
78 }
79 sort.Strings(keys)
80 h := md5.New()
81 for k, v := range keys {
82 h.Write([]byte(v))
83 h.Write([]byte{'='})
84 h.Write([]byte(params[v]))
85 if k < len(keys)-1 {
86 h.Write([]byte{'&'})
87 }
88 }
89 h.Write([]byte(mixinKey))
90 params["w_rid"] = hex.EncodeToString(h.Sum(make([]byte, 0, md5.Size)))
91 return params
92}
93
94func getWbiKeysCached() (string, string) {
95 if time.Since(lastUpdateTime).Minutes() > 10 {

Callers 1

SignURLFunction · 0.85

Calls 1

getMixinKeyFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…