瀏覽代碼

Create project

Jakub Sztandera 9 年之前
當前提交
27ae485d83
共有 2 個文件被更改,包括 40 次插入0 次删除
  1. 22 0
      README.md
  2. 18 0
      ipfs-swarm-key-gen/main.go

+ 22 - 0
README.md

@@ -0,0 +1,22 @@
+## ipfs-swarm-key-gen
+
+This program generates swarm.key file for ipfs Private Network feature
+
+### Installation
+
+```
+go get -u github.com/Kubuxu/go-ipfs-swarm-key-gen/ipfs-swarm-key-gen
+```
+
+### Usage
+
+```
+ipfs-swarm-key-gen > ~/.ipfs/swarm.key
+```
+
+Change `~/.ipfs/` to different directory if you use custom IPFS_PATH.
+
+
+### License
+
+MIT

+ 18 - 0
ipfs-swarm-key-gen/main.go

@@ -0,0 +1,18 @@
+package main
+
+import "crypto/rand"
+import "encoding/hex"
+import "fmt"
+import "log"
+
+func main() {
+	key := make([]byte, 32)
+	_, err := rand.Read(key)
+	if err != nil {
+		log.Fatalln("While trying to read random source:", err)
+	}
+
+	fmt.Println("/key/swarm/psk/1.0.0/")
+	fmt.Println("/base16/")
+	fmt.Print(hex.EncodeToString(key))
+}