Esempio n. 1
0
func LoadKey(crypto Crypto, keyFile, keyType string) error {
	var key interface{}
	var err error
	switch keyType {
	case "public":
		key, err = load.LoadPublic(keyFile)
	case "private":
		key, err = load.LoadPrivate(keyFile)
	}
	if err != nil {
		log.Println("ERROR: Crypto.LoadKey loading private key: ", err)
		return err
	}
	crypto.Key(key)
	return nil
}
Esempio n. 2
0
File: run.go Progetto: pdxjohnny/key
func Run() {
	message, err := ioutil.ReadFile(viper.GetString("message"))
	if err != nil {
		log.Println("ERROR: encrypt.Run error loading message: ", err)
		return
	}
	publicKey, err := load.LoadPrivate(viper.GetString("key"))
	if err != nil {
		log.Println("ERROR: encrypt.Run error loading private key: ", err)
		return
	}
	message, err = Decrypt(
		publicKey,
		message,
	)
	if err != nil {
		log.Println("ERROR: decrypt.Run error decrypting: ", err)
		return
	}
	fmt.Println(string(message))
	return
}