示例#1
0
func CountByByte(a, b [32]byte) int {
	n := 0
	for i := range a {
		n += pc.PopCount(uint64(a[i] ^ b[i]))
	}
	return n
}
示例#2
0
文件: main.go 项目: standyck/go-code
func othercrap() {
	f := tempconv.Fahrenheit(23)
	fmt.Fprintf(os.Stderr, "cf: %v\n", f)
	fmt.Fprintf(os.Stderr, "Freezing temp is %v\n", tempconv.FreezingC)
	fmt.Fprintf(os.Stdout, "celsius: %v\n", tempconv.FToC(f))
	HTTPClient = http.DefaultClient
	req, err := http.NewRequest("GET", "http://www.standyck.com", nil)
	if err != nil {
		fmt.Fprintf(os.Stdout, "err: %v\n", err)
	} else {
		r, _ := HTTPClient.Do(req)
		fmt.Fprintf(os.Stdout, "req: %v\n", req)
		fmt.Fprintf(os.Stdout, "response: %v\n", r)
	}

	z := popcount.PopCount(19235)
	fmt.Printf("popcount: %v\n", z)
}
示例#3
0
func main() {
	c1 := sha256.Sum256([]byte("x"))
	c2 := sha256.Sum256([]byte("X"))
	var temp uint8 = 0
	count := 0

	fmt.Println(len(c1))
	for i := 0; i < len(c1); i++ {
		if c1[i] != c2[i] {
			temp = ^(uint8(c1[i]) | uint8(c2[i]))
			fmt.Println(temp)
			count += popcount.PopCount(uint64(temp))
		}
	}
	fmt.Printf("%x\n%x\n%t\n%T\n", c1, c2, c1 == c2, c1)
	fmt.Printf("%d\n", count)
	// Output:
	// 2d711642b726b04401627ca9fbac32f5c8530fb1903cc4db02258717921a4881
	// 4b68ab3847feda7d6c62c1fbcbeebfa35eab7351ed5e78f4ddadea5df64b8015
	// false
	// [32]uint8
}
示例#4
0
func benchmarkPopCount(b *testing.B, size int) {
	for i := 0; i < size; i++ {
		pc.PopCount(0x1234567890ABCDEF)
	}
}
func BenchmarkPopcount(b *testing.B) {
	for i := 0; i < b.N; i++ {
		popcount.PopCount(0xFFFFFFFFFFFFFFFF)
	}
}
示例#6
0
func BenchmarkPopCount(b *testing.B) {
	for i := 0; i < b.N; i++ {
		popcount.PopCount(0x1234567890ABCDEF)
	}
}