Skip to content

Instantly share code, notes, and snippets.

@violetyk
Last active August 29, 2015 14:15
Show Gist options
  • Save violetyk/429b885d467d7a5b40d2 to your computer and use it in GitHub Desktop.
Save violetyk/429b885d467d7a5b40d2 to your computer and use it in GitHub Desktop.
md5とsha1とmapのソート
h := md5.New()
io.WriteString(h, "The fog is getting thicker!")
pp.Println(hex.EncodeToString((h.Sum(nil))))
h2 := sha1.New()
io.WriteString(h2, "The fog is getting thicker!")
pp.Println(hex.EncodeToString((h2.Sum(nil))))
s := "http://localhost:8080/xx/yy/zz/hogehoge.png:e?hoge=fuga&k=v#f"
pp.Println(url.QueryEscape(s))
pp.Println(len(s))
params := map[string]string{"b": "15", "z": "123123", "x": "sdf", "a": "12"}
length := len(params)
keys := make([]string, length)
i := 0
for k, _ := range params {
keys[i] = k
i++
}
sort.Strings(keys)
pp.Println(params)
i = 0
for i = 0; i < length; i++ {
pp.Println(keys[i], params[keys[i]])
}
j, _ := json.Marshal(params)
pp.Println(string(j))
h3 := sha1.New()
io.WriteString(h3, string(j))
pp.Println(hex.EncodeToString((h3.Sum(nil))))
pp.Println("finish")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment