示例#1
0
文件: keys.go 项目: robmurtha/goq
func updateKeyDir(location string, km dkeyczar.KeyManager, encrypter dkeyczar.Encrypter) {

	s := km.ToJSONs(encrypter)

	ioutil.WriteFile(location+"/meta", []byte(s[0]), 0600)

	for i := 1; i < len(s); i++ {
		fname := location + "/" + strconv.Itoa(i)
		ioutil.WriteFile(fname, []byte(s[i]), 0600)
	}
}
示例#2
0
文件: keys.go 项目: robmurtha/goq
func loadLocationReader(km dkeyczar.KeyManager, location string, crypter dkeyczar.Crypter) error {
	if location == "" {
		panic("missing required location argument")
	}

	lr := dkeyczar.NewFileReader(location)

	if crypter != nil {
		//fmt.Println("decrypting keys..")
		lr = dkeyczar.NewEncryptedReader(lr, crypter)
	}

	err := km.Load(lr)
	if err != nil {
		return fmt.Errorf("failed to load key: %s", err)
	}
	return nil
}
示例#3
0
func loadLocationReader(km dkeyczar.KeyManager, optLocation string, crypter dkeyczar.Crypter) bool {
	if optLocation == "" {
		fmt.Println("missing required --location argument")
		return false
	}

	lr := dkeyczar.NewFileReader(optLocation)

	if crypter != nil {
		fmt.Println("decrypting keys..")
		lr = dkeyczar.NewEncryptedReader(lr, crypter)
	}

	err := km.Load(lr)
	if err != nil {
		fmt.Println("failed to load key:", err)
		return false
	}
	return true
}