func (mk *MetaKey) Export(filename string) (err error) { buf := new(bytes.Buffer) err = mk.Write(buf) if err != nil { return } out := armour.EncodeBase64(buf.Bytes()) err = ioutil.WriteFile(filename, out, 0644) return }
func (mk *MetaKey) Export(password, filename string) (err error) { buf := new(bytes.Buffer) err = mk.Write(buf) if err != nil { return } pk := hash.DeriveKey(password) out := hash.New(buf.Bytes()).Digest() out = append(out, buf.Bytes()...) enc, err := armour.Encrypt(binaryKeyFromDerivedKey(pk), out, false) if err != nil { return } out = pk.Salt out = append(out, enc...) err = ioutil.WriteFile(filename, armour.EncodeBase64(out), 0644) return }