Ejemplo n.º 1
0
// DiffBits returns the number of bits that are different in two SHA256 hashes.
func DiffBits(c1, c2 [32]byte) int {
	var count int
	for i := range c1 {
		count += popcount.PopCount(uint64(c1[i] ^ c2[i]))
	}
	return count
}
Ejemplo n.º 2
0
func BenchmarkPopCount(b *testing.B) {
	for i := 0; i < b.N; i++ {
		popcount.PopCount(0x1234567890ABCDEF)
	}
}