├── README.md └── ipfs-swarm-key-gen └── main.go /README.md: -------------------------------------------------------------------------------- 1 | ## ipfs-swarm-key-gen 2 | 3 | This program generates swarm.key file for IPFS Private Network feature. 4 | 5 | ### Installation 6 | 7 | ``` 8 | go get -u github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm-key-gen 9 | ``` 10 | 11 | ### Usage 12 | 13 | ``` 14 | ipfs-swarm-key-gen > ~/.ipfs/swarm.key 15 | ``` 16 | 17 | Change `~/.ipfs/` to different directory if you use custom IPFS_PATH. 18 | 19 | 20 | ### License 21 | 22 | MIT 23 | -------------------------------------------------------------------------------- /ipfs-swarm-key-gen/main.go: -------------------------------------------------------------------------------- 1 | package main 2 | 3 | import "crypto/rand" 4 | import "encoding/hex" 5 | import "fmt" 6 | import "log" 7 | 8 | func main() { 9 | key := make([]byte, 32) 10 | _, err := rand.Read(key) 11 | if err != nil { 12 | log.Fatalln("While trying to read random source:", err) 13 | } 14 | 15 | fmt.Println("/key/swarm/psk/1.0.0/") 16 | fmt.Println("/base16/") 17 | fmt.Print(hex.EncodeToString(key)) 18 | } 19 | --------------------------------------------------------------------------------