MCPcopy
hub / github.com/eth0izzle/shhgit / GetEntropy

Function GetEntropy

core/util.go:58–71  ·  view source on GitHub ↗
(data string)

Source from the content-addressed store, hash-verified

56}
57
58func GetEntropy(data string) (entropy float64) {
59 if data == "" {
60 return 0
61 }
62
63 for i := 0; i < 256; i++ {
64 px := float64(strings.Count(data, string(byte(i)))) / float64(len(data))
65 if px > 0 {
66 entropy += -px * math.Log2(px)
67 }
68 }
69
70 return entropy
71}

Callers 1

processRepositoryOrGistFunction · 0.92

Calls

no outgoing calls

Tested by

no test coverage detected