Created
July 8, 2020 01:57
-
-
Save sshell/649fbdf713e5e35eff69647891eb563c to your computer and use it in GitHub Desktop.
faviconer.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"encoding/base64" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"github.com/twmb/murmur3" | |
) | |
func main() { | |
final := "" | |
fix := 76 | |
s := make([]string, 0) | |
// pull file from the internet | |
f, _ := http.Get("https://medium.com/favicon.ico") | |
content, _ := ioutil.ReadAll(f.Body) | |
str := base64.StdEncoding.EncodeToString(content) | |
// slice up string | |
for i := 0; i*fix+fix < len(str); i++ { | |
it := str[i*fix : i*fix+fix] | |
s = append(s, it) | |
} | |
// find last piece of string | |
findlen := len(s) * fix | |
last := str[findlen:] + "\n" | |
// put it all together | |
for _, s := range s { | |
final = final + s + "\n" | |
} | |
str = final + last | |
// do murmurhash3 stuff | |
mm3 := murmur3.StringSum32(str) | |
// convert uint32 to int32 | |
fmt.Println(int32(mm3)) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment