You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

26 lines
441 B

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