Beispiel #1
0
func generateKey(prefix, sid, name string) string {
	hash := md5.New()
	b := string551.StringToBytes(prefix + ":" + sid + ":" + name)
	hash.Write(b)
	return string551.HexBytesToString(hash.Sum(nil))

}
Beispiel #2
0
func (r *Router) getKeys(pattern string) []string {
	keys := []string{}

	patternBytes := string551.StringToBytes(pattern)
	coron := false

	keyBytes := []byte{}

	for i := 0; i < len(patternBytes); i++ {
		if patternBytes[i] == 0x3A {
			// 0x3A => ":"
			if !coron {
				keyBytes = []byte{}
				coron = true
			} else {
				keys = append(keys, string551.BytesToString(keyBytes))
				coron = false
			}
		} else {
			if coron {
				keyBytes = append(keyBytes, patternBytes[i])
			}
		}
	}

	return keys
}