Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- func hashify(appList []string, vectorLength int64) ([]int){
- hashedList := make([]int, vectorLength)
- for _, app := range appList {
- hashedValue := sha256.New()
- hashedValue.Write([]byte(app))
- hexStr := fmt.Sprintf("%x", hashedValue.Sum(nil))
- hexInt := new(big.Int)
- hexInt, ok := hexInt.SetString(hexStr, 16)
- if !ok {
- fmt.Println("error")
- panic("couldn't create bigint")
- }
- bigVectorLength := big.NewInt(vectorLength)
- modulo := new(big.Int)
- modulo = modulo.Mod(hexInt, bigVectorLength)
- moduloInt64 := modulo.Int64()
- hashedList[moduloInt64] += 1
- }
- return hashedList
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement