forked from JunwookHeo/bcsos
-
Notifications
You must be signed in to change notification settings - Fork 0
/
bcsos.go
59 lines (50 loc) · 1.27 KB
/
bcsos.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
package main
import (
"fmt"
"hash/fnv"
"log"
"math/big"
"net"
"strings"
"github.com/junwookheo/bcsos/common/wallet"
)
func init() {
log.SetFlags(log.LstdFlags | log.Lmicroseconds | log.Lshortfile)
}
func localAddresses() {
ifaces, err := net.Interfaces()
if err != nil {
log.Print(fmt.Errorf("localAddresses: %+v\n", err.Error()))
return
}
for _, i := range ifaces {
addrs, err := i.Addrs()
if err != nil {
log.Print(fmt.Errorf("localAddresses: %+v\n", err.Error()))
continue
}
log.Printf("iface : %v", i)
for _, a := range addrs {
ips := strings.Split(a.String(), "/")
nip := net.ParseIP(ips[0])
log.Printf("a : %v, ,nip : %v", a, nip.String())
log.Printf("To4 : %v, To16 : %v", nip.To4(), nip.To16())
}
}
}
func main() {
// localAddresses()
h1 := "0009ad6df4a2a0eb5f34f3d728044ce1fec0b05894f425f0625e935589195fd7"
n1, _ := new(big.Int).SetString(h1[len(h1)-52:], 16)
log.Printf("n1 = %v", n1)
h2 := "000c96e9ff47879778c43a593e7cafbd31bdd4104e5578b05368505727a4c9fa"
n2, _ := new(big.Int).SetString(h2[len(h2)-52:], 16)
log.Printf("n2 = %v", n2)
h := fnv.New64a()
h.Write([]byte(h1))
log.Printf("h : %v", h.Sum64())
h.Write([]byte(h1))
log.Printf("h : %v", h.Sum64())
h3 := wallet.DistanceXor(h1, h2)
log.Printf("h : %v", h3)
}