blockchainIDsystem/clientApp/keys.go
clientApp/keys.goRaw
1package main
2
3import (
4 "encoding/json"
5 "io/ioutil"
6
7 ownrsa "./ownrsa"
8)
9
10func readKeys(path string) []ownrsa.PackRSA {
11 var keys []ownrsa.PackRSA
12
13 file, err := ioutil.ReadFile(path)
14 check(err)
15 content := string(file)
16 json.Unmarshal([]byte(content), &keys)
17
18 return keys
19}
20
21func saveKeys(keys []ownrsa.PackRSA, path string) {
22 jsonKeys, err := json.Marshal(keys)
23 check(err)
24 err = ioutil.WriteFile(path, jsonKeys, 0644)
25 check(err)
26}